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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
v-yangliu-msft
Community Support
Community Support

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.

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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