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
Syndicate_Admin
Administrator
Administrator

How to use an IF and IN function in DAX

Hello

I'm trying to create a measure that basically says; If [Load Comp] - "Not Compliant" IN [TMS LINK] then "Not Compliant" Else "Compliant"

What I hope to achieve is that for each different instance in [TMS LINK] (for example, 101173549) it is "Compatible" or "Non-compliant" and this is determined by the [Load Comp] column.
There are 10 different values where 3 are "compatible" and 7 are "Non-compliant"
A value [TMS LINK] is classified as "Compliant" if all rows in [Load Comp] for that particular value are "Compliant"
(for example, 101173549 is "Not supported", where as 101173150 is "compliant")

Mobility.JPG

I've been trying to find an answer here, but to no ava pity and I'm new to using powerBI so it's been pretty hard to solve. Any help would be greatly appreciated.

1 ACCEPTED SOLUTION
v-yuaj-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

 

Based on your description, you can create a measure as follows.

My test table:

 

v-yuaj-msft_0-1611217767205.png

Measure:

Measure = 

var x1=IF(MAX('compatibale'[Load Comp])="Non-compliant",1,0)

var x2=SUMX(ALLEXCEPT(compatibale,compatibale[TMS LINK]),x1)

return

IF(x2>0,"Non-compliant","Compliant")
 
Result:

v-yuaj-msft_1-1611217842745.png

 

Hope that's what you were looking for.

Best Regards,

Yuna

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
v-yuaj-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

 

Based on your description, you can create a measure as follows.

My test table:

 

v-yuaj-msft_0-1611217767205.png

Measure:

Measure = 

var x1=IF(MAX('compatibale'[Load Comp])="Non-compliant",1,0)

var x2=SUMX(ALLEXCEPT(compatibale,compatibale[TMS LINK]),x1)

return

IF(x2>0,"Non-compliant","Compliant")
 
Result:

v-yuaj-msft_1-1611217842745.png

 

Hope that's what you were looking for.

Best Regards,

Yuna

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@Syndicate_Admin , if you want look at mutiple lines for this. This as a new column can work

 

new column =
var _count = countx(filter(Table,[TMS LINK] =earlier([TMS LINK]) && [Load Comp] = "Not Compliant"),[TMS LINK])
return
if(isblank(_count) ,"Compliant", "Not Compliant")

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.