Forum Discussion

revisr's avatar
revisr
New Member
2 years ago
Solved

If statement too many arguments

I am brand new to DAX. In one of my lessons I was told to enter an IF statement:   Customer Age = IF(     FORMAT('Customer'[Birth Date], "mmdd") <= FORMAT(TODAY(), "mmdd"),     DATEDIFF('Custo...
  • uzuntasgokberk's avatar
    2 years ago

    Hello revisr,

     

    If statement syntax is IF(<logical_test>, <value_if_true>[, <value_if_false>])

    IF function (DAX) - DAX | Microsoft Learn

    Therefore, you code should be like this:


    IF(
       FORMAT('Customer'[Birth Date]"mmdd") <= FORMAT(TODAY(), "mmdd"),

       DATEDIFF('Customer'[Birth Date]TODAY(), YEAR),

           IF(

              FORMAT('Customer'[Birth Date]"mmdd") > FORMAT(TODAY(), "mmdd"),

             DATEDIFF('Customer'[Birth Date], TODAY(), YEAR),

             1

               )

    )

     

    Kind Regards,
    Gökberk Uzuntaş

    📌 If this post helps, then please consider Accepting it as a solution and giving Kudos — it helps other members find answers faster!

    🔗 Stay Connected:
    📘 Medium |
    📺 YouTube |
    💼 LinkedIn |
    📷 Instagram |
    🐦 X |
    👽 Reddit |
    🌐 Website |
    🎵 TikTok |