Forum Discussion

PradeepDive's avatar
PradeepDive
Helper II
4 years ago
Solved

Need Help - Filter tables using OR criteria from two table

Hi, I have three tables and want to filter one out of 3 based on column values in other two tables    Here is the explaination    Table 1 --  Project ID, Resource ID, Hrs   Table 2 -- Projec...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi PradeepDive ,

     

    You can use LOOKVALUE function. However, if there is a relationship between tables, it's more efficient to use the RELATED function.

     

    Sample data.

    Table 1

     

    Table 2

     

    Table 3

     

     

    1.If there're no relationships.

    You can create a calculated table as follows.

    Table =
    SUMMARIZE (
        FILTER (
            ADDCOLUMNS (
                'Table 1',
                "c1",
                    LOOKUPVALUE (
                        'Table 2'[Project ID],
                        'Table 2'[Project ID], 'Table 1'[Project ID]
                    ),
                "c2",
                    LOOKUPVALUE (
                        'Table 3'[Resource ID],
                        'Table 3'[Resource ID], 'Table 1'[Resource ID]
                    )
            ),
            [c1] = [Project ID]
                && [c2] = [Resource ID]
        ),
        [Hrs],
        [Project ID],
        [Resource ID]
    )
    

     

     

    If there're relationships.

    You can create a calculated table as follows..

    Table 4 =
    SUMMARIZE (
        FILTER (
            ADDCOLUMNS (
                'Table 1',
                "c1", RELATED ( 'Table 2'[Project ID] ),
                "c2", RELATED ( 'Table 3'[Resource ID] )
            ),
            [c1] = [Project ID]
                && [c2] = [Resource ID]
        ),
        [Hrs],
        [Project ID],
        [Resource ID]
    )
    

     

     

    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.