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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
cmckinney
Helper IV
Helper IV

IF statement not recognizing table

I am writing an if statement in a measure that says essentially: IF( 'table'[this_date] > 'table'[that_date], 1, 0) but for some reason Power BI is not recognizing the table/columns. The table reference in the statement is grey for some reason and I am not sure why. I expected the statement to recognize the table.

 

My literal statement is:

Pass_Fail_Flag = IF( 'test vPassFailTestResults'[Last Failed] > 'test vPassFailTestResults'[Last Passed], 0, 1)
 
See Bellow screenshot:2020-12-14_15-21-03.png
3 REPLIES 3
v-rzhou-msft
Community Support
Community Support

Hi @cmckinney 

Stanislav_dugas and PhilipTreacy 's reply is helpful. Your dax statement will work well in calculated column instead of measure. Measure will return to aggregation, you need to use max function to get date value.

For more details about difference between measure and calculated column you may refer to blogs as below:

Calculated Columns and Measures in DAX

Calculated Columns vs Measures

Could you tell me if your problem has been solved? If it is, kindly Accept the helpful reply as the solution. More people will benefit from it. Or you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file from your Onedrive for Business.

 

Best Regards,

Rico Zhou

PhilipTreacy
Super User
Super User

Hi @cmckinney 

You need to aggregate the data in someway when creating a measure so you need to write something like this

 

Pass_Fail_Flag = IF( MAX('test vPassFailTestResults'[Last Failed]) > MAX('test vPassFailTestResults'[Last Passed]), 0,1 ) 

 

pf.png

Alternatively you could create a Calculated Column and your current syntax would then work without using an aggregation function.

regards

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


stanislav_dugas
Helper III
Helper III

I am not an expert but when you are trying to create a refference to column inside a meassure you need to use a function like sum/average/distinc.

possible calculation could look like this but it wont give you exactly what you need. but just so you have an idea of how it would look like.

A=Calculate(if(sum('test vPassFailTestResults'[Last Failed])> sum( 'test vPassFailTestResults'[Last Passed]), 0, 1))

 

Otherwise why dont you create a column? Same function as you have there but instead of meassure create a column. Or is there a particular reason you need to have it as meassure?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.