Forum Discussion

powerbidev123's avatar
powerbidev123
Solution Sage
28 days ago
Solved

Dax help

Age = YEAR(UTCNOW())- MID('Application'[Date of Birth],7,4) . here MID('Application'[Date of Birth],7,4) is text value , how can i make it integer in dax in the same formula
  • Greg_Deckler's avatar
    28 days ago

    powerbidev123 Multiply by 1.

    Age = YEAR(UTCNOW())- ( MID('Application'[Date of Birth],7,4) * 1 )
  • Shai_Karmani's avatar
    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

     

    Let's connect in LinkedIn