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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

"IF" not working properly

Hello,

 

There is a measure that calculates the days between two dates.

Time = DATEDIFF(MAX('Detailed DED Analysis'[DocumentDate]),max(Miro[Belgetrh]),DAY)

 

I have an IF column that I implement for this result. But it's not working properly. I have indicated in the picture the ones that do not work properly. How can I fix?

 

Status = IF([Time] >= 0,"OK","NOT OK")
 
koray_0-1637139629395.png

 

9 REPLIES 9
Anonymous
Not applicable

Hello @selimovd 

 

Thank you for help.

I already wrote that I used it this way in the first message. But it doesn't work properly that way. Unfortunately my problem is not solved 😞

Hey @Anonymous ,

 

yes, but your description is not very detailed, so it's kind of hard to find out why there is the error.

Can you share the file? It's easier to take a look at the problem.

 

Thank you and best regards

Denis

 

selimovd
Super User
Super User

Hey @Anonymous ,

 

is the [Status] a calculated column or a measure?

Be aware that calculated columns are static, so they will not change the value depending on the filter context. Once the table is loaded the value stays the same.

Measures are dynamic, so depending on the filter context the value will change with every change of the data (change of rows, slicer, etc.)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 
Anonymous
Not applicable

Hello @selimovd 

 

Thank you for reply.

Status is column. When I change it to Measure, the table gets corrupted. Is there a way to build from scratch what I want to do? I want to find the number of days between "DocumentDate" date and "Belgetrh". And I want it to write NOT ok if the result is less than 0, OK if it is greater than 0.

 

Thank you.

Hey @Anonymous ,

 

if your data is not changing, a calculated column is fine. But as you see wrong results, I guess you need something dynamic.

For a measure you always need an aggregation like SUM, MAX or something similar. The following syntax should work as a measure:

 

Status =
IF (
    MAX ( myTable[Time] ) >= 0,
    "OK",
    "NOT OK"
)

 

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 
Anonymous
Not applicable

Hello @selimovd 

 

It gives error.

 

koray_0-1637145059517.png

 

Hello @Anonymous ,

 

yes, because the formula requires not only the column name, but also the table name where the column [Time] is.

Take a look at my example, just put the name of the table before the column like this myTable[Time] or if the table has spaces 'my Table'[Time].

 

Then you won't get an error.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 
Anonymous
Not applicable

Hello @selimovd 

 

Sorry, it gives error again 😞

koray_0-1637146354747.png

Time is measure like as bellow.

Time = DATEDIFF(MAX('Detailed DED Analysis'[DocumentDate]),max(Miro[Belgetrh]),DAY)

 

 

Hey @Anonymous ,

 

if it's a measure then you don't need an aggregation. Then the following measure should work:

Status =
IF (
    [Time] >= 0,
    "OK",
    "NOT OK"
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Solution Authors