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
Anonymous
Not applicable

May i know how to sort the Aging 1- 30 come first

Hi All

Paulyeo11_0-1605599201813.pngPaulyeo11_1-1605599219820.png

 

1 ACCEPTED SOLUTION
jaideepnema
Solution Sage
Solution Sage

@Anonymous create a calculated column as shown below

jaideepnema_0-1605603383572.png

here is the code

Ageing Sort = SWITCH(TRUE(),

AND(Query1[AGING]>0,Query1[AGING]<=30),1,

AND(Query1[AGING]>30,Query1[AGING]<=60),2,

AND(Query1[AGING]>60,Query1[AGING]<=90),3,

AND(Query1[AGING]>90,Query1[AGING]<=120),4,

AND(Query1[AGING]>120,Query1[AGING]<=150),5,

AND(Query1[AGING]>150,Query1[AGING]<=180),6,BLANK())

Untitled.png

 

this wil sort the column and you will get the required output as shown below

Untitled 2.png

 

Appreciate a Kudos if this resolved your query !!

View solution in original post

7 REPLIES 7
jaideepnema
Solution Sage
Solution Sage

@Anonymous create a calculated column as shown below

jaideepnema_0-1605603383572.png

here is the code

Ageing Sort = SWITCH(TRUE(),

AND(Query1[AGING]>0,Query1[AGING]<=30),1,

AND(Query1[AGING]>30,Query1[AGING]<=60),2,

AND(Query1[AGING]>60,Query1[AGING]<=90),3,

AND(Query1[AGING]>90,Query1[AGING]<=120),4,

AND(Query1[AGING]>120,Query1[AGING]<=150),5,

AND(Query1[AGING]>150,Query1[AGING]<=180),6,BLANK())

Untitled.png

 

this wil sort the column and you will get the required output as shown below

Untitled 2.png

 

Appreciate a Kudos if this resolved your query !!

Anonymous
Not applicable

Hi @Anonymous 

Create a new table with age or Days in Asceding to descending order and have an index from 1 

In Power Query > you can create a table from existing table. (right click, Duplicate and remove other columns except Days/Age) and add column Index from 1

Join this new Table with your existing table and in your graph use this new table index in tooltip to sort as ascending/Desc.

 

Hope this helps.

 

Cheers,

-Namish B

amitchandak
Super User
Super User

@Anonymous , Try a new column like

Aging 1 = [Aging]

Aging Sort = switch( true() ,
[Aging] ="1- 30" , 1 ,
[Aging] ="30-60" , 2 ,
// keep on adding
,8
)

 

and sort Aging 1 on Aging  sort and use that in visual

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
Anonymous
Not applicable

Hi Amit

I get Aging Sort error :-

Paulyeo11_0-1605601406209.png

 

@Anonymous , I have given two new columns, not one. The first I create to avoid circular dependencies

Aging 1 = [Aging]

 

Aging Sort = switch( true() ,
[Aging] ="1- 30" , 1 ,
[Aging] ="30-60" , 2 ,
// keep on adding
,8
)

 

Aging sort will become sort column of aging 1 and you will use aging 1 in visual

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
Anonymous
Not applicable

Hi Amit

Still have error :-

Paulyeo11_0-1605602384621.png

 

Anonymous
Not applicable

Hi Amit

Below script dont need to sort  , case closed:- 

AGING =
var _datediff=Datediff([AR Invoice Date],today(),day)
return
SWITCH(
TRUE(),
_datediff<=30,"1 to 30 Day",
_datediff<=30,"31 to 60 Day",
_datediff<=61,"61 to 90 Day",
_datediff<=91,"91 to 120 Day",
_datediff<=120,"121 to 150 Day",
_datediff<=151,"151 to 180 Day",
"Over 181 day"
)

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.