2 Replies Latest reply on Sep 12, 2018 4:45 AM by Sami N

    Using Sum and Count with IF or case statement

    Sami N



      I am having 3 datasource connections  with the fields listed below

      and a common table as company to join these three with only 3 values A,B and C

      A- Visit_ID

      B - ID

      C - total_Visits_by_ID


      I m trying to get a count of visits  by using the query



      sum(if [ Company]='A'                then count([Visit_id])

      ELSEIF [ Company]='B'              then count([ID])

      else Sum(total_Visits_by_ID)




      I have tried encapsulating the above in Sum , Count, Min functions  aslo tried the use of CASE  but

      Tableau is throwing an error as -"Cannot Mix Aggregate or Non aggregate comparisions"


      i would like to use count and Sum to get the number of visits


      any ideas