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! Request now

Reply
Anonymous
Not applicable

Dax - If statement with true logic that has a condition

Hello,

 

I'm trying to achive the following: 

 

Metric

Value1

Measure

Test1

0

9999

thisisatest

9999

false

Test3

1234

false

 

Ive writteh the following DAX formula:

Measure= IF(MAX(Table[Metric]) = "Test1", CALCULATE(SUM(Table[Value]),Table[Metric] = "thisisatest"),false)
 
It works well if the data source is excel but it doesn't work if I'm using a stored prodedure (SQL Server)
Both are direct imports.
 
Any idea how I can fix this?
Thanks
1 ACCEPTED SOLUTION
Anonymous
Not applicable

I got it to work 🙂

I had to use a filter in my calculation.

 

Thank you for you help!

View solution in original post

3 REPLIES 3
RobbeVL
Impactful Individual
Impactful Individual

Hi there, 
 


@Anonymous wrote:
 
"It works well if the data source is excel but it doesn't work if I'm using a stored prodedure (SQL Server)
Both are direct imports."

Are you using Direct Query or Import?...

 

If you are using import, there should be any difference in how to calculate a measure.
Check if your datatypes are set up the same.

Anonymous
Not applicable

Oh sorry, I'm using import.

My data types are the same in both.

 

I also tried to assign a variable for the CALCULATE() statement and use that in the IF statement. The variable returns the correct value however if I use the variable in the if statement it only returns a blank cell.

If I use the IF statement and use "123" insteat of the variable it returns "123" as expected

Anonymous
Not applicable

I got it to work 🙂

I had to use a filter in my calculation.

 

Thank you for you help!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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