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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
RyanHare92
Helper I
Helper I

Find match to all possible combinations

The following has been driving me crazy for the last couple of days and I can't seem to come up with a solution in DAX. Any help is appreciated.

I have a table of items with their types:

IDType
ID1A
ID1B
ID1D
ID2X
ID2Y
ID3X
ID3Y
ID3Z


and I have another table that shows what combination of types form each group:

TypesGroup
A1
B1
A2
B2
C2
A3
B3
D3
X4
Z4
X5
Z5
Y5
X6
Y6


How can I put something together that would check every type for each ID and, with every combination of those types, inform me which groups they could be part of (not all types have to be used). The expected result would be the following:

IDTypeRelevant Group(s)
ID1A1 & 3
ID1B1 & 3
ID1D1 & 3
ID2X6
ID2Y6
ID3X4, 5 & 6
ID3Y4, 5 & 6
ID3Z4, 5 & 6

 

Alternivelty, if the specific groups can't be informed, a simple "Yes" to indicate that a possible group exists for the existing types will suffice.

 

I have been trying to get this to work with the following thought process (I haven't translated this into DAX because I still don't know how I can do the last part):

  1. Filter second table with all the types to get all possible groups.
  2. For all the groups flagged, check if all the required types exist for that ID.

 

Many thanks in advance. 


1 ACCEPTED SOLUTION

@RyanHare92 

Relevant Group(s) = 
VAR CurrentType = ItemTypes[Type]   -- First Table in Question
VAR CurrentID = ItemTypes[ID]       -- First Table in Question
VAR Groups =
    VALUES ( TypesGroup[Group] )    -- Second Table in Question
VAR SameRows =
    CALCULATETABLE (
        VALUES ( ItemTypes[Type] ),
        ItemTypes[ID] = CurrentID,
        REMOVEFILTERS ( ItemTypes )
    )
VAR SetIntersection =
    FILTER (
        Groups,
        VAR Types =
            CALCULATETABLE ( DISTINCT ( TypesGroup[Types] ) )
        VAR RemoveRows =
            EXCEPT ( Types, SameRows )
        RETURN
            COUNTROWS ( RemoveRows ) = 0
    )
VAR Result =
    CONCATENATEX ( SetIntersection, TypesGroup[Group], ", " )
RETURN 
    Result

 

AntrikshSharma_0-1696605362109.png

 

View solution in original post

4 REPLIES 4
AntrikshSharma
Super User
Super User

@RyanHare92 There is no association between ID and the second table, so how do you identify that? Why ID2 X/Y have 6?

@AntrikshSharma Because group 6 is formed by X and Y and ID2 has both types X and Y.

@RyanHare92 

Relevant Group(s) = 
VAR CurrentType = ItemTypes[Type]   -- First Table in Question
VAR CurrentID = ItemTypes[ID]       -- First Table in Question
VAR Groups =
    VALUES ( TypesGroup[Group] )    -- Second Table in Question
VAR SameRows =
    CALCULATETABLE (
        VALUES ( ItemTypes[Type] ),
        ItemTypes[ID] = CurrentID,
        REMOVEFILTERS ( ItemTypes )
    )
VAR SetIntersection =
    FILTER (
        Groups,
        VAR Types =
            CALCULATETABLE ( DISTINCT ( TypesGroup[Types] ) )
        VAR RemoveRows =
            EXCEPT ( Types, SameRows )
        RETURN
            COUNTROWS ( RemoveRows ) = 0
    )
VAR Result =
    CONCATENATEX ( SetIntersection, TypesGroup[Group], ", " )
RETURN 
    Result

 

AntrikshSharma_0-1696605362109.png

 

Worked like a charm! What a legend!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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