Forum Discussion
Year Diff with Slicer
- 3 years ago
Hi ,
How about this:
SWITCH ( TRUE, 'Query1'[Year Diff] < 1,"<1", 'Query1'[Year Diff] >= 1 && 'Query1'[Year Diff] <= 3,"1-3", 'Query1'[Year Diff] >= 4 && 'Query1'[Year Diff] <= 5,"4-5", ">5" )
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
KW123 ,
Create a new column with an if statement where you implement your logic like
if table[YearDifference] < 1 then "<1 year" else
if table[YearDifference] >= 1 and table[YearDifference] < 3 then "1-3 years" else
if table[YearDifference] >= 3 and table[YearDifference] < 5 then "3-5 years" else
">5 Years "
Note, the code above is just a pseudo code. You have to google the right syntax yourself depending on whether you are using DAX code or Power Query's M.
Does this help? 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
I have that but I am not sure where to put the ELSE. It seems as though the DAX works for <1 and 1-3 but it is not producing the 4-5 or >5
- tackytechtom3 years agoMost Valuable Professional
Hi ,
How about this:
SWITCH ( TRUE, 'Query1'[Year Diff] < 1,"<1", 'Query1'[Year Diff] >= 1 && 'Query1'[Year Diff] <= 3,"1-3", 'Query1'[Year Diff] >= 4 && 'Query1'[Year Diff] <= 5,"4-5", ">5" )
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/- KW1233 years agoHelper V
tackytechtom
Thank you so much, this is exactly what I am looking for!