Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext 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
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
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 46 | |
| 43 | |
| 39 | |
| 19 | |
| 15 |
| User | Count |
|---|---|
| 68 | |
| 67 | |
| 31 | |
| 27 | |
| 24 |