Forum Discussion
Anonymous
3 years agoNot applicable
DAX to Format a Slicer
Hello, I have a FundingDate column in my table.
I wanted to add a year slicer from that date column like below
I wanted to display current year as YTD ie (2022 as YTD)
I wrote 3 calculated columns
Cal_Year = Year(FundingDate)
CurrentYear = Year(Today())
FormattedYear = if( cal_year = currentYear, "YTD", cal_year) -- this calculated column throws an error saying expressions that yield variant data type cannot be used to define calculated columns.
How do i resolve this issue?
Please Help
Thanks,
Dharani
Try this formule:
FormattedYear = if([CurrentYear]=[Cal_Year_],"YTD", LEFT('Table'[Cal_Year_],4))
3 Replies
- Bifinity_75
Solution Sage
Hi Anonymous , the reason is because in the column you are throwing text and date, the solution can be this:
FormattedYear = if([CurrentYear]=[Cal_Year_],"YTD",format('Table'[Cal_Year_],"YYYY"))Best regards
- AnonymousNot applicable
If i use this, for 2022 its showing YTD and for the rest of the years its showing 1905
- Bifinity_75
Solution Sage
Try this formule:
FormattedYear = if([CurrentYear]=[Cal_Year_],"YTD", LEFT('Table'[Cal_Year_],4))