Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
I am brand new to DAX. In one of my lessons I was told to enter an IF statement:
Solved! Go to Solution.
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 |
That did it thanks!!
Hi revisr,
Looks like the formula @uzuntasgokberk provided was unnecessarily complex. You were on the right track with your original measure. You just had an extra comma in your measure, before the -1 at the end. The comma made Power BI think the -1 was a fourth argument in your IF function. Hopefully that makes sense.
You had:
IF (
FORMAT ( 'Customer'[Birth Date], "mmdd" ) <= FORMAT ( TODAY(), "mmdd" ),
DATEDIFF ( 'Customer'[Birth Date], TODAY(), YEAR ),
DATEDIFF ( 'Customer'[Birth Date], TODAY(), YEAR ), - 1
)
However, what you meant was:
IF (
FORMAT ( 'Customer'[Birth Date], "mmdd" ) <= FORMAT ( TODAY(), "mmdd" ),
DATEDIFF ( 'Customer'[Birth Date], TODAY(), YEAR ),
DATEDIFF ( 'Customer'[Birth Date], TODAY(), YEAR ) - 1
)
Proud to be a Super User! | |
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 |
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.
User | Count |
---|---|
12 | |
11 | |
10 | |
9 | |
8 |