Forum Discussion
How to combine 2 expression into 1 ?
Hi All
I have below 2 seperate expression :-
That's because it needs to be defined as a new calculated table, not a measure or calculated column. See the example I attached previously.
14 Replies
- VahidDM
Super User
Hi admin11
Try this:
Show Last 3 or 4 Yr = VAR _Y3 = 'DATE'[Year] >= YEAR ( TODAY () ) - 3 VAR _Y4 = 'DATE'[Year] >= YEAR ( TODAY () ) - 4 RETURN IF ( 'DATE'[Year] >= _Y3, 3, IF ( 'DATE'[Year] = _Y4, 4, 0 ) )it will return 3 for the first 3 years and 4 for a year before that.
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/- admin11
Memorable Member
Hi VahidDM
Thank you for your sharing . i get error :-
DAX comparison operations do not support comparing values of type Integer with values of type True/False. Consider using the VALUE or FORMAT function to convert one of the values.
my PBI sample file :-
https://www.dropbox.com/s/rf7o60s9y0yhxpd/show%203%20or%204%20yr.pbix?dl=0
Hope you can take a look
Paul
- VahidDM
Super User
My bad.
Try this:
Show Last 3 or 4 Yr = VAR _Y3 = YEAR ( TODAY () ) - 3 VAR _Y4 = YEAR ( TODAY () ) - 4 RETURN IF ( 'DATE'[Year] >= _Y3, 3, IF ( 'DATE'[Year] = _Y4, 4, 0 ) )If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/