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
PBI_newuser
Post Prodigy
Post Prodigy

Create and sort Week Duration by descending order

Hi,

I would like to create a column "Week Duration" start from Sunday to Saturday.

For example:
23-Aug-20 to 29-Aug-20

30-Aug-20 to 05-Sep-20

06-Sep-20 to 12-Sep-20

 

After "Week Duration" column is created, how to sort it by descending order in line chart?

Expected Output:

 

PBI_newuser_0-1613555007919.png

 

1 ACCEPTED SOLUTION

Hi, @PBI_newuser 

You can try the following steps.

 

1 Create a Calculated column

rank_column = RANKX(data,INT(data[Week Start Date]),,DESC,Dense)

 

2 Sort  ‘Week Duration’  column by this column

v-cazheng-msft_0-1614136052077.png

 

The result looks like this:

v-cazheng-msft_1-1614136052080.png

 

Here is the pbix.

 

Best Regards,

Caiyun Zheng

 

 

View solution in original post

6 REPLIES 6
v-cazheng-msft
Community Support
Community Support

Hi, @PBI_newuser 

You can create a column with whole number as its value and then sort your “Week Duration” column with this column. You can refer this article Sort a Column with a Custom Order in Power BI.

 

Best Regards,

Caiyun Zheng

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-cazheng-msft , thanks for your suggestion. But the week duration is continous and updating everyday. How can I create a column with whole number for that? Sample data here.

Hi, @PBI_newuser 

You can try the following steps.

 

1 Create a Calculated column

rank_column = RANKX(data,INT(data[Week Start Date]),,DESC,Dense)

 

2 Sort  ‘Week Duration’  column by this column

v-cazheng-msft_0-1614136052077.png

 

The result looks like this:

v-cazheng-msft_1-1614136052080.png

 

Here is the pbix.

 

Best Regards,

Caiyun Zheng

 

 

Hi @v-cazheng-msft, it works!! Thank you so much for your help! 😉

amitchandak
Super User
Super User

@PBI_newuser ,

if the format is sortable then from three dots you can choose week and Sort descending.

 

Otherwise, create a sort column and mark that as the sort column

refer my video : https://youtu.be/KK1zu4MBb-c

 

or https://docs.microsoft.com/en-us/power-bi/desktop-sort-by-column

Hi @amitchandak , it doesn't work for my case.

Could you please take a look at my file?

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.