Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
zraopingm
Helper IV
Helper IV

IF STATEMENT ERROR

Hello, 

Image 1 is working; image 2 is a copy of same measure with a new name. but why I have this error as displayed in Image 2? same data model ( DAXsql lesson), see image3. 

Thank you 

Zoey

 

zraopingm_0-1749231400167.png

 

zraopingm_1-1749231499577.png

 

 

zraopingm_2-1749231523047.png

 

 

 

 

1 ACCEPTED SOLUTION
SamsonTruong
Super User
Super User

Hi @zraopingm ,

This is due to your working calculation being a calculated column, and your non-working one being a measure. Calculated columns are evaluated per each row in your base table, so it calculates without any issues. However, how the measure calculates varies on how it is aggregrates in your visual. Due to this it could pull in multiple records for each date, not knowing which one to compare. To fix your measure, you can apply a max() around your dates so it only pulls in one date. However, as a note, this may give a different than expected output depending on your use case.

Here is the updated measure:

Delivery State1 =
IF (
    MAX(Sales[Delivery Date]) - MAX(Sales[Order Date]) >= [Avg All Delivery],
    "Above Average",
    "Below Average"
)

  

If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.

Thanks,

Samson

View solution in original post

3 REPLIES 3
SamsonTruong
Super User
Super User

Hi @zraopingm ,

This is due to your working calculation being a calculated column, and your non-working one being a measure. Calculated columns are evaluated per each row in your base table, so it calculates without any issues. However, how the measure calculates varies on how it is aggregrates in your visual. Due to this it could pull in multiple records for each date, not knowing which one to compare. To fix your measure, you can apply a max() around your dates so it only pulls in one date. However, as a note, this may give a different than expected output depending on your use case.

Here is the updated measure:

Delivery State1 =
IF (
    MAX(Sales[Delivery Date]) - MAX(Sales[Order Date]) >= [Avg All Delivery],
    "Above Average",
    "Below Average"
)

  

If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.

Thanks,

Samson

I got you!! thank you Zoey

Glad to hear it worked!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.