Forum Discussion
Add column with if condition
- 4 years ago
Hi, dokat
Column = SWITCH( TRUE(), [CY] = dt"2018-12-31", "2018", [CY] = dt"2017-12-31", "2017", [CY] = dt"2019-12-31", "2019", [CY] = dt"2020-12-31", "2020", [CY] = dt"2021-12-31", "last year", [CY] = dt"2022-02-28", "last month" )Result:
Hope this helps.
Best Regards,
Community Support Team _ Zeon ZhengIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
dokat , You are trying to do two thing here.
New column
Month Name = format([Date], "mmm")
YTD for this year as column
YTD = if([Date] >= date(year([Date]),1,1) && [Date] <= today() , "YTD", "Not YTD" )
Also refer
Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA
amitchandak formula returned not right values
Ultimately 'Tier'[CY] = 12/31/2021 then return "last year" in the new colun
If 'Tier'[CY] = 12/31/2021 return last year
if 'Tier'[CY] = 2/28/2022 return last month
if 'Tier'[CY] =12/31/2018 return 2018
if 'Tier'[CY] =12/31/2017 return 2017
if 'Tier'[CY] =12/31/2019 return 2019
if 'Tier'[CY] =12/31/2020 return 2020
Please see below screen shot fo rthe results of the formula. Thanks