Forum Discussion

ddorhout's avatar
ddorhout
Frequent Visitor
5 years ago
Solved

Check for matching group in two separate tables

I have a new problem that I am facing, that seems to be similar to the previous topic.   I have one main table in which I have an overview of all the users and the items that they need. There are ...
  • selimovd's avatar
    5 years ago

    Hey ddorhout ,

     

    that is possible.

    Please check the following calculated column. I wrote the comments what exactly is going on in the formula:

    Result = 
    -- the User of the current row
    VAR vUserCurrentRow = 'Table 1'[Column 1]
    
    -- the Item of the current row
    VAR vItemCurrentRow = 'Table 1'[Column 2]
    
    -- Filter of Table 2 to the current user and selection of the related groups
    VAR vTableGroupUser =
        SELECTCOLUMNS(
            FILTER(
                'Table 2',
                'Table 2'[Column X] = vUserCurrentRow
            ),
            "@Group", 'Table 2'[Column Y]
        )
    
    -- Filter of Table 3 to the current item and selection of the related groups
    VAR vTableGroupItem =
        SELECTCOLUMNS(
            FILTER(
                'Table 3',
                'Table 3'[Column A] = vItemCurrentRow
            ),
            "@Group", 'Table 3'[Column B]
        )
    
    -- Intersection of the two tables. If there is a group in table 2 for the current user
    -- and group in table 3 for the current item we find a match here
    VAR vIntersection =
        INTERSECT(
            vTableGroupUser,
            vTableGroupItem
        )
    
    -- we count if there is a match / if one row is left after the intersection
    VAR vAmountRowsIntersection =
        COUNTROWS( vIntersection )
    
    RETURN
    
    -- If there is row we return "Yes", otherwiese "no"
        IF(
            vAmountRowsIntersection > 0,
            "Yes",
            "No"
        )

     

    The result is identical to your desired result:

     

    If you need any help please let me know.
    If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
     
    Best regards
    Denis