Forum Discussion
TRICKY - SWITCH DAX MEASURE
Hi Experts
I am stuck on the following measure which is only returning back the result for the measure [18+] but excluding [52+] and so on
"18+" should be the sum of all the indivdual measure for [18+] + [52+] + [64+] + [70+] + [78+] + [90+] + [104+] - not just [18+]
Measure
Measure_Switch =
If(Hasonevalue(RTT[Type]),
Switch(Selectedvalue(RTT[Type]),
"Under 18",[Under_18],
"18+", [18+] + [52+] + [64+] + [70+] + [78+] + [90+] + [104+],
"52+",([52+] + [64+] + [70+] + [78+] + [90+] + [104+]),
"64+",([64+] + [70+] + [78+] + [90+] + [104+]),
"70+",([70+] + [78+] + [90+] + [104+]),
"78+",([78+] + [90+] + [104+]),
"90+",([90+] + [104+]),
"104+",([104+]),
"Clock Stop",[Clock_Stops]
))
Hi Anonymous,
I don't think there is a need to create these many measures. Why don't you try something like this:
Measure_Switch = IF(HASONEVALUE(RTT[Type]), SWITCH(SELECTEDVALUE(RTT[Type]), "Under 18", SUMX('Table',IF('Table'[Value]<18,1,0)), "18+", SUMX('Table',IF('Table'[Value]>=18 && 'Table'[Value]<52,1,0)), "52+", SUMX('Table',IF('Table'[Value]>=52 && 'Table'[Value]<64,1,0)), "64+", SUMX('Table',IF('Table'[Value]>=64 && 'Table'[Value]<70,1,0)), "70+", SUMX('Table',IF('Table'[Value]>=70 && 'Table'[Value]<78,1,0)), "78+", SUMX('Table',IF('Table'[Value]>=78 && 'Table'[Value]<90,1,0)), "90+", SUMX('Table',IF('Table'[Value]>=90 && 'Table'[Value]<104,1,0)), "104+",SUMX('Table',IF('Table'[Value]>=104,1,0)) ))Mark this post as a solution if that works for you!
4 Replies
- ShauryaMemorable Member
Hi Anonymous,
I don't think there is a need to create these many measures. Why don't you try something like this:
Measure_Switch = IF(HASONEVALUE(RTT[Type]), SWITCH(SELECTEDVALUE(RTT[Type]), "Under 18", SUMX('Table',IF('Table'[Value]<18,1,0)), "18+", SUMX('Table',IF('Table'[Value]>=18 && 'Table'[Value]<52,1,0)), "52+", SUMX('Table',IF('Table'[Value]>=52 && 'Table'[Value]<64,1,0)), "64+", SUMX('Table',IF('Table'[Value]>=64 && 'Table'[Value]<70,1,0)), "70+", SUMX('Table',IF('Table'[Value]>=70 && 'Table'[Value]<78,1,0)), "78+", SUMX('Table',IF('Table'[Value]>=78 && 'Table'[Value]<90,1,0)), "90+", SUMX('Table',IF('Table'[Value]>=90 && 'Table'[Value]<104,1,0)), "104+",SUMX('Table',IF('Table'[Value]>=104,1,0)) ))Mark this post as a solution if that works for you!
- AnonymousNot applicable
Hi The question is not about range of values but adding up individual measure that sum up to give [18+]
- ShauryaMemorable Member
Hi Anonymous,
What is it that you are calculating in those individual measures?
- mangaus1111Solution Sage
Hi Anonymous,
can you please send us a screenshot from Excel with the columns of your table and the expected result . Without that it is difficult to give you help.