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

Create measure based on another filter - "IF(MAX(...) in ALLSELECTED(...), TRUE, FALSE) not working

Hi all,

 

I have a table that looks like this

learner4eva_1-1643003015311.png

And I have created 2 tables to create 2 independent filters.

FruitsList = SUMMARIZE(Fruits, Fruits[Fruits])
SellerList = SUMMARIZE(Fruits, Fruits[Seller])
 
I have created 2 measures
 
IsFruit = IF(max(Fruits[Fruits]) in ALLSELECTED(FruitsList[Fruits]),1,0)
IsSeller = IF(max(Fruits[Seller]) in ALLSELECTED(SellerList[Seller]),1,0)
 
I noticed that IsSeller is not working correctly when I choose "A" as the Seller.
Apple, Banana, Pineapple should show up as 1 under "IsSeller" column but only "Banana" is showing up as 1.
 
Can you help me understand why and how should I fix the measure? Thank you!
 
learner4eva_2-1643003091925.png

 

 

 

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

Hi @Anonymous ,

 

Why not working correctly:

The reason why incorrectly is the MAX() function.When you choose Slicer "A", The result of Seller table filtered by the slicer is one row {"A"} (as the following), and also the result of ALLSELECTED(SellerList[Seller]).

vchenwuzmsft_0-1643252609768.png

But for the first row of Matrix visual, Apple, it has tow rows in its filter context.

vchenwuzmsft_1-1643252822922.png

This contributes the result of max(Fruits[Seller]) is "C", so "C" is not in {"A"}. result of if is 0.

 

 

Workaround:

We can try another algorithm to implement the retrieval of whether fruit exists in the table of choices from the slicerlist. Try the code below.

 

IsSeller =
VAR _fruit =
    COUNTROWS( VALUES( Fruits[Seller] ) )
VAR _except =
    COUNTROWS(
        EXCEPT( VALUES( Fruits[Seller] ), ALLSELECTED( SellerList[Seller] ) )
    )
VAR _r = _fruit - _except
RETURN
    IF( _r > 0, 1, 0 )

 

result:

vchenwuzmsft_2-1643256930473.png

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

4 REPLIES 4
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous ,

 

Why not working correctly:

The reason why incorrectly is the MAX() function.When you choose Slicer "A", The result of Seller table filtered by the slicer is one row {"A"} (as the following), and also the result of ALLSELECTED(SellerList[Seller]).

vchenwuzmsft_0-1643252609768.png

But for the first row of Matrix visual, Apple, it has tow rows in its filter context.

vchenwuzmsft_1-1643252822922.png

This contributes the result of max(Fruits[Seller]) is "C", so "C" is not in {"A"}. result of if is 0.

 

 

Workaround:

We can try another algorithm to implement the retrieval of whether fruit exists in the table of choices from the slicerlist. Try the code below.

 

IsSeller =
VAR _fruit =
    COUNTROWS( VALUES( Fruits[Seller] ) )
VAR _except =
    COUNTROWS(
        EXCEPT( VALUES( Fruits[Seller] ), ALLSELECTED( SellerList[Seller] ) )
    )
VAR _r = _fruit - _except
RETURN
    IF( _r > 0, 1, 0 )

 

result:

vchenwuzmsft_2-1643256930473.png

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

Samarth_18
Community Champion
Community Champion

Hi @Anonymous ,

Create a measure with below code:-

isSeller = 
var selected_value = VALUES(SellerList[Seller])
return IF(MAX(Fruits[Seller]) in selected_value,1,0)
isFruit = 
var selected_value = VALUES(FruitsList[Fruits])
return IF(max(Fruits[Fruits]) in selected_value ,1,0)

Output:-

Samarth_18_0-1643011524557.png

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

VahidDM
Super User
Super User

Hi @Anonymous 

 

Make sure there is no relationship between your new tables and main table.

Use Values rather than SUMMARIZE.

FruitsList = VALUES ( Fruits[Fruits] )
SellerList = VALUES ( Fruits[Seller] )
then
IsFruit = IF(max(Fruits[Fruits]) in VALUES ( Fruits[Fruits] ),1,0)
IsSeller = IF(max(Fruits[Seller]) in VALUES ( Fruits[Seller] ),1,0)
 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/


 

Anonymous
Not applicable

Hi, I followed the instructions but unfortunately it is not working

 

learner4eva_0-1643010678849.png

 

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