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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
danielbrownau
Regular Visitor

Custom Month Sort Order

I'm trying to create a sort order for months, but where the current month = 1, next month = 2, next next month = 3, etc.


I've tried a couple of measures, but not sure on how to start with this one.


Any help would be greatly appreciated.

1 ACCEPTED SOLUTION
v-lionel-msft
Community Support
Community Support

Hi @danielbrownau ,

 

For your issue, you can do like this:

First, create a ‘datediff’ column by ‘DATEDIFF()’ function:

datediff = DATEDIFF(NOW(), Sheet1[Date], MONTH)

Second, create a ‘month_order’ column by ‘IF’ function:

month_order = 
IF(
    Sheet1[datediff] = 0,
    1,
    Sheet1[datediff] + 1
)

The result is as follows:

h4.PNG

 

Best regards,

Lionel Chen

 

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

View solution in original post

3 REPLIES 3
v-lionel-msft
Community Support
Community Support

Hi @danielbrownau ,

 

For your issue, you can do like this:

First, create a ‘datediff’ column by ‘DATEDIFF()’ function:

datediff = DATEDIFF(NOW(), Sheet1[Date], MONTH)

Second, create a ‘month_order’ column by ‘IF’ function:

month_order = 
IF(
    Sheet1[datediff] = 0,
    1,
    Sheet1[datediff] + 1
)

The result is as follows:

h4.PNG

 

Best regards,

Lionel Chen

 

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

Hi @v-lionel-msft 

 

Perfect! Thank you for the assistance, works like a charm, and even over several past years.

Thank you again.

 

DB

Hi @danielbrownau ,

 

I think it's better to use RANKX() function:

Column = 
VAR now_date = MONTH(NOW())
RETURN
RANKX(
   ALL(Sheet1),
   DATEDIFF(now_date, Sheet1[date], MONTH),
    ,
    1,
   Dense
)

DATEDIFF(): https://docs.microsoft.com/en-us/dax/datediff-function-dax

RANKX(): https://docs.microsoft.com/en-us/dax/rankx-function-dax

 

Best regards
Lionel Chen

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.