Forum Discussion
DATEDIFF with IF statement?
- 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" ) )
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" ) )- Reine7 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
- Reine7 years agoHelper IV
Hi - now that I have patient ages, I need to be able to pull all patients in a given time period and show how many people there are in each age group - age groups being <18, 18-39, 40-59, 60+.
Can you help me figure that out as well? Sorry - I wasn't thinking about this yesterday or I would have asked for both at the same time.
Thank you :)