2 Replies Latest reply on Apr 19, 2018 7:59 AM by Zhouyi Zhang

    How do I count the number of occurrences meeting 2 criteria?

    Tiago-Mateus Korynek

      I have a set of data which has a column for the Location and a column for the Code.


      What I would like to do is to count up how many times each Location has had a Code 41 so that I can then eventually present a graph with for example RTG, ERU, UGR along the X-axis and then the number of Code 41's they have had in the period of time on the Y-axis.


      Currently I have been using the following:


      IF COUNT([Location])>0 THEN COUNT([Location])

      ELSE 0



      And this has enabled me to calculate how many 41s + 46s are present. When I try adding a criteria to isolate just the 41s, such as using an AND Code = "41" I get an error saying Cannot mix aggregate and non-aggregate functions with this function. Sounds like it should be an easy one to resolve and I am just having a bit of a stupid moment.


      Any help would be greatly appreciated and I am using Tableau 10.4.1.