Forum Discussion
Dax help
- 28 days ago
powerbidev123 Multiply by 1.
Age = YEAR(UTCNOW())- ( MID('Application'[Date of Birth],7,4) * 1 ) - 28 days ago
Wrap the MID with VALUE() to convert the text to a number:
Age = YEAR(UTCNOW()) - VALUE(MID('Application'[Date of Birth], 7, 4))INT() also works, but VALUE is the more idiomatic choice when the string is a plain number.
One heads up: if [Date of Birth] is actually a date column you can skip MID entirely and just use YEAR('Application'[Date of Birth]). Also bear in mind this returns a rough age based on year only, without checking whether the birthday has passed this year.
If this helped, a thumbs up and accepting the solution would be appreciated.
Thanks,
Shai Karmani
Wrap the MID with VALUE() to convert the text to a number:
Age = YEAR(UTCNOW()) - VALUE(MID('Application'[Date of Birth], 7, 4))
INT() also works, but VALUE is the more idiomatic choice when the string is a plain number.
One heads up: if [Date of Birth] is actually a date column you can skip MID entirely and just use YEAR('Application'[Date of Birth]). Also bear in mind this returns a rough age based on year only, without checking whether the birthday has passed this year.
If this helped, a thumbs up and accepting the solution would be appreciated.
Thanks,
Shai Karmani