Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi everyone,
Hope you are all well.
I used the following two calculations to get my Date Numbered column:
Solved! Go to Solution.
@Anonymous I think this measure may give you the correct result (edited to change the switch year to SELECTEDVALUE() instead of MIN())
DateNumbered =
VAR _maxDate_2020 =
CALCULATE (
MAX ( 'Table'[Date] ),
ALL ( 'Table'[Date] ),
YEAR ( 'Table'[Date] ) = 2020
)
VAR _maxDate_2019 =
CALCULATE (
MAX ( 'Table'[Date] ),
ALL ( 'Table'[Date] ),
YEAR ( 'Table'[Date] ) = 2019
)
VAR _dayspast =
SWITCH (
YEAR ( SELECTEDVALUE ( 'Table'[Date] ) ),
2020,
CALCULATE (
DATEDIFF ( SELECTEDVALUE ( 'Table'[Date] ), _maxDate_2020, DAY ) + 1
),
2019,
CALCULATE (
DATEDIFF ( SELECTEDVALUE ( 'Table'[Date] ), _maxDate_2019, DAY ) + 1
),
BLANK ()
)
RETURN
_dayspast
Respectfully,
Zoe Douglas (DataZoe)
Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/
@Anonymous I think this measure may give you the correct result (edited to change the switch year to SELECTEDVALUE() instead of MIN())
DateNumbered =
VAR _maxDate_2020 =
CALCULATE (
MAX ( 'Table'[Date] ),
ALL ( 'Table'[Date] ),
YEAR ( 'Table'[Date] ) = 2020
)
VAR _maxDate_2019 =
CALCULATE (
MAX ( 'Table'[Date] ),
ALL ( 'Table'[Date] ),
YEAR ( 'Table'[Date] ) = 2019
)
VAR _dayspast =
SWITCH (
YEAR ( SELECTEDVALUE ( 'Table'[Date] ) ),
2020,
CALCULATE (
DATEDIFF ( SELECTEDVALUE ( 'Table'[Date] ), _maxDate_2020, DAY ) + 1
),
2019,
CALCULATE (
DATEDIFF ( SELECTEDVALUE ( 'Table'[Date] ), _maxDate_2019, DAY ) + 1
),
BLANK ()
)
RETURN
_dayspast
Respectfully,
Zoe Douglas (DataZoe)
Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/
@Anonymous , Not very clear, Try like
MaxDate =
var _max CALCULATE(MAX('Table'[Date]),ALL('Table'[Date]))
return
date(year(_max)-1,month(_max), day(_max))
DateNumbered = CALCULATE(DATEDIFF(SELECTEDVALUE('Table'[Date]),[MaxDate],DAY)+1)
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 59 | |
| 43 | |
| 42 | |
| 23 | |
| 17 |
| User | Count |
|---|---|
| 190 | |
| 122 | |
| 96 | |
| 66 | |
| 47 |