Forum Discussion

cjcj's avatar
cjcj
Icon for Helper I rankHelper I
3 years ago
Solved

Switch with multiple conditions from 2 tables

Hi, is there a way to set swich with mutiple conditions from 2 tables? follwowing works fine for 1 condition from 1 table.   TEST =  sumx(   'table1',      Switch (       True(),          'tab...
  • v-yanjiang-msft's avatar
    3 years ago

    Hi cjcj ,

    If you can't use the RELATED function, you can modify the formula like this:

    TEST =
    VAR _T =
        ADDCOLUMNS (
            'table1',
            "temp",
                MAXX (
                    FILTER ( 'table2', 'table2'[ID] = EARLIER ( table1[ID] ) ),
                    'table2'[temp]
                )
        )
    RETURN
        SUMX (
            _T,
            SWITCH (
                TRUE (),
                [color] = "RED"
                    && [temp] = "WARM", 2345,
                [color] = "BLUE"
                    && [temp] = "HOT", 1345
            )
        )
    

    It can also get the correct result.

    I attach my sample below for your reference.

     

    Best Regards,
    Community Support Team _ kalyj

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