powerbissasdaxmsbi

Unable to deploy SSAS project. reason : The syntax of 'Birthdate' is incorrect


I created the following Dax expression to calculate the Age

Age :=
VAR Birthdate = DIM_CUSTOMER[DATEOFBIRTH]
VAR ThisDay =TODAY ()
VAR IntBirthdate =
    YEAR ( Birthdate ) * 10000
        + MONTH ( Birthdate ) * 100
        + DAY ( Birthdate )
VAR IntThisDay =
    YEAR ( ThisDay ) * 10000
        + MONTH ( ThisDay ) * 100
        + DAY ( ThisDay )
VAR Age =
    QUOTIENT ( IntThisDay - IntBirthdate; 10000 )
VAR CheckedAge =
    DIVIDE ( Age; NOT ISBLANK ( Birthdate ) )
RETURN
    CheckedAge

The result of Age DAX expression in SSAS

It seems that it work perfectly But, when I tried to Deploy the project I got the following ERROR

"Impossible de déployer les métadonnées. Raison : La syntaxe pour 'Birthdate' est incorrecte. La colonne calculée 'DIM_CUSTOMER[Age]' contient une erreur de syntaxe. Entrez une formule valide."

the ERROR screenshot


Solution

  • That's a really weird age calculation. I don't understand why you're dividing by a date for CheckedAge.

    Why not something like this?

     Age := DATEDIFF ( DIM_CUSTOMER[DATEOFBIRTH], TODAY (), YEAR )
    

    or

    Age := DIVIDE ( DATEDIFF ( DIM_CUSTOMER[DATEOFBIRTH], TODAY (), DAY ), 365.25 )