Forum Discussion
Reine
7 years agoHelper IV
DATEDIFF with IF statement?
Hello :) I have made a column in my report table to calculate the age from the date of birth using DATEDIFF. Upon seeing the data, I realize that I need to add something so that if the age is less th...
- 7 years ago
My guess is you are getting converion errors with the IF? Try something like this:
Age = VAR AgeCalc = DATEDIFF ( [LaddersT.PersonT(PersonID).BirthDate], TODAY (), YEAR ) RETURN IF ( AgeCalc < 5, "Unknown", FORMAT ( AgeCalc, "00" ) )
jdbuchanan71
7 years agoSuper User
My guess is you are getting converion errors with the IF? Try something like this:
Age =
VAR AgeCalc =
DATEDIFF ( [LaddersT.PersonT(PersonID).BirthDate], TODAY (), YEAR )
RETURN
IF ( AgeCalc < 5, "Unknown", FORMAT ( AgeCalc, "00" ) )Reine
7 years agoHelper IV
Woohoo! this works perfectly - thank you so much :) I am new to Power BI as well as DAX so it's all a bit foreign to me still. I'll study this to better understand what you've done. I really appreciate your help - I spent hours trying to figure it out. ugh