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.
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
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
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 )
Check out the November 2023 Power BI update to learn about new features.
Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.
130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.