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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
rprice3312
Frequent Visitor

Age Categories not working properly - leveling issue?

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")

 

AgeCatImage.png

1 ACCEPTED SOLUTION
MariaP
Solution Supplier
Solution Supplier

Download Sample PBIX: Age Example

AgesShownByBins.PNGHi, 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.

View solution in original post

2 REPLIES 2
MariaP
Solution Supplier
Solution Supplier

Download Sample PBIX: Age Example

AgesShownByBins.PNGHi, 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.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors