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.
Hello:
My goal is very simple - create "age categories" based on the Age2 measure field so that I can stratify by age groups. The code below works as indicated by the screenshot below. However, when I remove the Age2 field, the results are inaccurate as only one category remains which is clearly not correct. I suspect it's because the DAX expression below needs another statement to level according to the dimension that I want to display the age groups by?
Any advice is appreciated. I'm very new to writing DAX and apologize if this is very basic. I have an SSAS Tabular model and am trying to use DAX to create these groups rather than having to build into the model.
Regards,,
Rob
DAX:
Age Category = SWITCH(TRUE(),
AND([Age2]>=0, [Age2]<=60),"<60",
AND([Age2]>60,[Age2]<70),"61-70",
"Older than 70")
Solved! Go to Solution.
Download Sample PBIX: Age Example
Hi, Are you trying to show result as shown? You can add an index column to your Age table and use your existing DAX to add your Groupings as a new colum. Results shown above.
Download Sample PBIX: Age Example
Hi, Are you trying to show result as shown? You can add an index column to your Age table and use your existing DAX to add your Groupings as a new colum. Results shown above.
Yes, that's the outcome I'm trying to achieve. The Tabular Model is not available for me to alter, I have to use a calculated measure to achieve my desired result. I will try your idea above and I do appreciate your reply.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
100 | |
80 | |
64 | |
58 |
User | Count |
---|---|
148 | |
111 | |
94 | |
84 | |
67 |