1 Reply Latest reply on Aug 23, 2016 12:47 PM by chris.moore.11

    Count number of times in row measures based on Criteria

    Shakila Abdul Subhan

      Hello Tableau Users,

       

      We have a requirement to find how many times "1" appears, "2" appears", "3" appears from Measure1 to Measure5 based on criteria for each country.

      Could you please provide suggestions or solution.

       

       

       

      CountryMeasure1Measure2Measure3Measure4Measure5
      USA13312
      CANADA31113
      EUROPE33311
      AUSTRALIA21212

       

       

      Criteria:

       

      1               2              3

       

       

      Output:

       

        

      CountryMeasure1Measure2Measure3Measure4Measure5No of Times "1" appearsNo of Times "2" appearsNo of Times "3" appears
      USA13312212
      CANADA31113302
      EUROPE33311203
      AUSTRALIA21212230

       

      Thanks

      Shakila

        • 1. Re: Count number of times in row measures based on Criteria
          chris.moore.11

          You could make three calculated fields for the three columns you are looking to add.

           

          --

          No of Times "1" appears:

          (if [Measure1] = 1 then 1 else 0 end)

          +

          (if [Measure2] = 1 then 1 else 0 end)

          +

          (if [Measure3] = 1 then 1 else 0 end)

          +

          (if [Measure4] = 1 then 1 else 0 end)

          +

          (if [Measure5] = 1 then 1 else 0 end)

           

          --

          No of Times "2" appears:

          (if [Measure1] = 2 then 1 else 0 end)

          +

          (if [Measure2] = 2 then 1 else 0 end)

          +

          (if [Measure3] = 2 then 1 else 0 end)

          +

          (if [Measure4] = 2 then 1 else 0 end)

          +

          (if [Measure5] = 2 then 1 else 0 end)

           

          --

          No of Times "3" appears:

          (if [Measure1] = 3 then 1 else 0 end)

          +

          (if [Measure2] = 3 then 1 else 0 end)

          +

          (if [Measure3] = 3 then 1 else 0 end)

          +

          (if [Measure4] = 3 then 1 else 0 end)

          +

          (if [Measure5] = 3 then 1 else 0 end)