Forum Discussion
Dynamic SWITCH TIME Statement
- 6 years ago
Hi,
Please try this calculated column:
Tiers = IF ( YEAR ( 'Table'[Date] ) = YEAR ( TODAY () - 3 ), "CY", "PY" & DATEDIFF ( 'Table'[Date], TODAY () - 3, YEAR ) )The result shows:
See my attached pbix file.
Best Regards,
Giotto
The information you have provided is not making the problem clear to me. Can you please explain with an example.
Appreciate your Kudos.
I am trying to avoid hardcoding any years like in the example below.
I want to put a formula instead of an actual year which will provide a respective yearso that I don't have to updates manually the years in the statement every year.
Tiers =
SWITCH (
TRUE (),
'Weekly Data'[Injury_Dte] = 2020, 'CY'
'Weekly Data'[Injury_Dte] = 2019, 'PY 1'
'Weekly Data'[Injury_Dte]) = 2018, 'PY 2'
.....
">PY6"
)
- v-gizhi-msft6 years agoCommunity Support
Hi,
Please try this calculated column:
Tiers = IF ( YEAR ( 'Table'[Date] ) = YEAR ( TODAY () - 3 ), "CY", "PY" & DATEDIFF ( 'Table'[Date], TODAY () - 3, YEAR ) )The result shows:
See my attached pbix file.
Best Regards,
Giotto