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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
codeman71
Frequent Visitor

Determine if any of a list of values exists in another list

Hoping you Power BI masters might be able to help me out.

 

I have a list of Features that exist on Vehicles. I'm using a Matrix Visual to show which features are on which vehicles. It looks like this:

 

 Vehicle 1Vehicle 2Vehicle 3Vehicle 4
+ Domain AX XX
+ Domain B XXX
- Domain C    
   Feature 1 [ID12]X X 
   Feature 2 [ID13] X  
   Feature 3 [ID14] X  
+ Domain D  XX

 

The problem arises when I collapse the rows into the Domains that the Features are grouped under. In my Measure for calculating the 'X', I used the MAX() function to handle when more than one Feature is selected by the visual. Here's my logic:

 

 

 

Feature Exists = 
var _Feature = MAX(Features[Feature ID])

return
CALCULATE(
    IF(
        _Feature in VALUES('Vehicles'[Feature ID])
        ,"X"
        )
)

 

 

 

So the problem is that when I collapse the Domain, Power BI only looks at the highest Feature ID and shows if it is on the vehicle. What I'd like to know is if ANY of the features on that domain are on that vehicle. In essence, I'd like to do something like:

 

 

Feature Exists = 
var _Feature = VALUES(Features[Feature ID])

 

 

 

But this of course causes an error in Power BI as it only wants to have a single value to look at, and not a range of values.

 

Is there another way I might be able to indicate if any of the features on a Domain are on a vehicle, to put the X in that column when that row is collapsed?

 

From my example above, when collapsing Domain C, I'd like for it to have an X for Vehicle 1, 2, and 3.

 

Desired Output (excerpt only):

 Vehicle 1Vehicle 2Vehicle 3Vehicle 4
+ Domain CXXX 

 

My current logic output:

 Vehicle 1Vehicle 2Vehicle 3Vehicle 4
+ Domain C X  

 

Because in Domain C with 3 features, Feature 3 has the largest ID.

 

Thanks so much!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @codeman71 ,

 

Here's my solution.

1.Replace your original X with 1.

Feature Exists = 
var _Feature = MAX(Features[Feature ID])
return
CALCULATE(
    IF(
        _Feature in VALUES('Vehicles'[Feature ID])
        ,1
        )
)

 

2.Create a new measure.

Measure = 
var _sum=SUMX('Features',[Feature Exists])
var _flag=IF(HASONEVALUE(Features[Feature Name]),[Feature Exists],_sum )
return   IF(_flag>0,"X",BLANK())

 

3.Here's the result.

vstephenmsft_0-1639561548897.png

 

 

Best Regards,

Stephen Tao

 

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

3 REPLIES 3
Anonymous
Not applicable

Hi @codeman71 ,

 

Here's my solution.

1.Replace your original X with 1.

Feature Exists = 
var _Feature = MAX(Features[Feature ID])
return
CALCULATE(
    IF(
        _Feature in VALUES('Vehicles'[Feature ID])
        ,1
        )
)

 

2.Create a new measure.

Measure = 
var _sum=SUMX('Features',[Feature Exists])
var _flag=IF(HASONEVALUE(Features[Feature Name]),[Feature Exists],_sum )
return   IF(_flag>0,"X",BLANK())

 

3.Here's the result.

vstephenmsft_0-1639561548897.png

 

 

Best Regards,

Stephen Tao

 

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

codeman71
Frequent Visitor

Thanks @parry2k. I created a new file that shows the issue.

 

Here's how the data looks in the visual:

codeman71_0-1639068778066.png

 

One other oddity that results from this logic is that when you minimize some of these Domains, because the highest ID number may not be applied to a vehicle, that category just disappears. In my example, if you minimize Domain A or Domain C, they disappear from the Matrix visual, because the highest numbered item isn't applied to a vehicle.

 

Link to sample file

 

Thanks for any ideas you might have!

parry2k
Super User
Super User

@codeman71 interesting problem to solve, can you share sample pbix file using one drive/google drive, and remove any sensitive information before sharing.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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