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
ambi95
Helper I
Helper I

How to sort based on text column which will change every week

Hi, I am stuck here.

Attached is the matrix i have on PBI. 

ambi95_1-1680772040596.png

The column headers are static data entered as a text type, showcasing a week's date range. This data will change every week.

How can i sort it in such a way that (in this example) 30th March - 5th Apr is first, 6th - 12th Apr is second, and then > 13th Apr is third.

I'm really confused, if anyone could provide an alternative to sorting directly also, that would work.

Just need anything that works

 

@amitchandak 

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

see my video
https://1drv.ms/v/s!AiUZ0Ws7G26RhxEUJVRvC1njL21i?e=MSsHdp
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
https://1drv.ms/u/s!AiUZ0Ws7G26RhxCRRw-4sg9a49rB?e=F4gmfQ

List.Max(
List.Transform(
Text.Split([#"ColB - Copy"],"-"),(x)=> 
Number.From(try Date.FromText(Text.Trim(x), [Format = "dd MMM yy", Culture = "en-EN"])otherwise 
Date.FromText(Text.Trim(x), [Format = "dd MMM yy", Culture = "en-EN"]
))))

View solution in original post

9 REPLIES 9
Ahmedx
Super User
Super User

see my video
https://1drv.ms/v/s!AiUZ0Ws7G26RhxEUJVRvC1njL21i?e=MSsHdp
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
https://1drv.ms/u/s!AiUZ0Ws7G26RhxCRRw-4sg9a49rB?e=F4gmfQ

List.Max(
List.Transform(
Text.Split([#"ColB - Copy"],"-"),(x)=> 
Number.From(try Date.FromText(Text.Trim(x), [Format = "dd MMM yy", Culture = "en-EN"])otherwise 
Date.FromText(Text.Trim(x), [Format = "dd MMM yy", Culture = "en-EN"]
))))

this worked! thanks a ton

@Ahmedx thanks a lot for the support, i will try this solution and keep you updated on the progress.

Ahmedx
Super User
Super User

Share sample pbix file to help you.

Link to Sample Files 

@Ahmedx  please check above link

ambi95
Helper I
Helper I

@Ahmedx can you please elaborate? i am a fairly new PBI user

@Ahmedx thanks so much for the links, but my main problem is that the data will change every week , as you can see it is weekly data. How can i implement dynamic custom sorting? 

Ahmedx
Super User
Super User

you need to add an index column next to
Column header and it must be dynamic.
write how you enter the name of these columns as text?

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.