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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Encounter problem in Sort in Pivot table

Hi All

 

My below 2 expression work fine :-

 

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",
_datediff<=181,"181 to 210 Day",
_datediff<=211,"211 to 250 Day",
_datediff<=251,"251 to 270 Day",
_datediff<=271,"271 to 300 Day",
_datediff<=301,"301 to 330 Day",
_datediff<=331,"331 to 360 Day",
"Over 361 day"
)
 
AGING Sort_ =
var _datediff=Datediff([AR Invoice Date],today(),day)
return
SWITCH(
TRUE(),
_datediff<=30,1,
_datediff<=30,2,
_datediff<=61,3,
_datediff<=91,4,
_datediff<=120,5,
_datediff<=150,6,
_datediff<=180,7,
_datediff<=210,8,
_datediff<=240,9,
_datediff<=270,10,
_datediff<=300,11,
_datediff<=330,12,
_datediff<=360,13,
 
14
)
 
 

But when i try to create pivot table , i cannot sort by AR Aging Period.

Paulyeo11_0-1610341465735.png

 

https://www.dropbox.com/s/dki63npflq8wwsv/PBT_V2021_89%20SORT%20BY%20AGING.pbix?dl=0

 

Paul

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Have you marked the sort column correctly. Because in matrix column( Pivot) only sort column or natural sort will work.

Refer to my video on this -https://www.youtube.com/watch?v=KK1zu4MBb-c

 

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

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , Have you marked the sort column correctly. Because in matrix column( Pivot) only sort column or natural sort will work.

Refer to my video on this -https://www.youtube.com/watch?v=KK1zu4MBb-c

 

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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