Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hi I have date table from 2023 to 2025 i want a column with month series where 36 being december 2025 and 1 being January 2023.
Solved! Go to Solution.
@esam not sure what your Date table looks like, I simply Assumed that you have only 1 column table as Calendar[Date]
Column =
RANKX (
'Calendar',
DATE ( MONTH ( 'Calendar'[Date] ), YEAR ( 'Calendra'[Date] ), 1 ),
,
ASC,
DENSE
)
Hi @FreemanZ
The solution you provided gave something similar but not accurate it is giving me result in negative
for jan 2023 it is one than feb 2023 0 and for december 2025 -33
Thank you for the solution @FreemanZ can you explain a bit how this logic is working here !!
also how to get better with dax with real world scenarios
hi @esam
there is no secret, as long as you know the DATEDIFF function, which returns the number of periods between two dates. In this case, the period is MONTH.
In general, learning DAX by doing. Try to bring change and value to your daily work with DAX. If time allows, come back to the community and try to contribute.
You could try a calculated column like
Month series =
VAR ReferenceDate = 'Date'[Date]
VAR PrevMonths =
CALCULATETABLE (
VALUES ( 'Date'[Year month] ),
REMOVEFILTERS ( 'Date' ),
'Date'[Date] < ReferenceDate
)
RETURN
COUNTROWS ( PrevMonths ) + 1
Removefilter with comparison operator is not correct
I think maybe you've missed a close bracket, the REMOVEFILTERS and comparison are separate.
the series generated by this 13,12,....1
OK, the below works for me
Month series =
VAR ReferenceDate = 'Date'[Date]
VAR PrevMonths =
CALCULATETABLE (
DISTINCT ( 'Date'[Year month] ),
REMOVEFILTERS ( 'Date' ),
'Date'[Date] <= ReferenceDate
)
RETURN
COUNTROWS ( PrevMonths )
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
25 | |
21 | |
20 | |
14 | |
13 |
User | Count |
---|---|
43 | |
37 | |
25 | |
24 | |
23 |