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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
gussie
Frequent Visitor

Sort Calculated Column by Some Index

gussie_0-1617764809973.png

Hello, 

I keep getting this error - I am truing to sort customer lifespan by days active - however it keeps coming up with this error above.

gussie_1-1617764873973.png

 

Can anyone help me with this issue? 

The calculated column is in dax -->

years_months_days_active = 

VAR days = dim_account[Query1.days_active]

VAR years = ROUNDDOWN(days / 365, 0)

VAR days_remainder_year = MOD(days, 365)

VAR months = ROUNDDOWN(days_remainder_year / 30, 0)

VAR days_remainder_months = MOD(days_remainder_year, 30)

RETURN

SWITCH(

TRUE(),

days = BLANK() || days_remainder_months = 0, BLANK(),

years = 0 && months = 0, days_remainder_months & "d",

years = 0, months & "m " & days_remainder_months & "d",

years & "y " & months & "m " & days_remainder_months & "d"

)



 

2 REPLIES 2
Anonymous
Not applicable

Hi  @gussie  ,

I used your calculated column and created the following data:

v-yangliu-msft_0-1617952831220.png

1. Click [customer lifespan], select Column tools – Sort by column – [Query1.days_active]v-yangliu-msft_1-1617952831226.png

2. Result:

My data will be sorted correctly

v-yangliu-msft_2-1617952831227.png

Is your Power bi Desktop version the latest version, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@gussie , this means you have one value for which you have more than one sort index.

 

Refer my video where I discussed these issues: https://www.youtube.com/watch?v=KK1zu4MBb-c

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.