This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
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.
Solved! Go to Solution.
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:
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 @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:
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.
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
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 36 | |
| 33 | |
| 31 | |
| 24 | |
| 18 |
| User | Count |
|---|---|
| 68 | |
| 50 | |
| 33 | |
| 24 | |
| 24 |