Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Invesco
Helper V
Helper V

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]

))

1 ACCEPTED SOLUTION
Shaurya
Memorable Member
Memorable Member

Hi @Invesco,

 

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!

View solution in original post

4 REPLIES 4
mangaus1111
Solution Sage
Solution Sage

Hi @Invesco,

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.

Shaurya
Memorable Member
Memorable Member

Hi @Invesco,

 

What is it that you are calculating in those individual measures?

Shaurya
Memorable Member
Memorable Member

Hi @Invesco,

 

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!

Hi The question is not about range of values but adding up individual measure that sum up to give [18+]

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.