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

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.

 Country Measure1 Measure2 Measure3 Measure4 Measure5 USA 1 3 3 1 2 CANADA 3 1 1 1 3 EUROPE 3 3 3 1 1 AUSTRALIA 2 1 2 1 2

Criteria:

1               2              3

Output:

 Country Measure1 Measure2 Measure3 Measure4 Measure5 No of Times "1" appears No of Times "2" appears No of Times "3" appears USA 1 3 3 1 2 2 1 2 CANADA 3 1 1 1 3 3 0 2 EUROPE 3 3 3 1 1 2 0 3 AUSTRALIA 2 1 2 1 2 2 3 0

Thanks

Shakila

• ###### 1. Re: Count number of times in row measures based on Criteria

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)