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

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.

Reply
Paulyeo11
Impactful Individual
Impactful Individual

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

@Paulyeo11 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

@Paulyeo11 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 !!

NamishB
Post Prodigy
Post Prodigy

Hi @Paulyeo11 

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

@Paulyeo11 , 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

Hi Amit

I get Aging Sort error :-

Paulyeo11_0-1605601406209.png

 

@Paulyeo11 , 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

Hi Amit

Still have error :-

Paulyeo11_0-1605602384621.png

 

Paulyeo11
Impactful Individual
Impactful Individual

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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