Forum Discussion

Anandakash's avatar
Anandakash
Microsoft Employee
4 years ago
Solved

Help with PowerBi Dax(Filtering a Table with contains)

let say i have 2 table A, B like below: Table A= Type value a 10 a+b 6 a+b+c 4 b+c 5   Table B= Type a b c   I have a slicer created from Table B. I...
  • v-yanjiang-msft's avatar
    4 years ago

    Hi Anandakash ,

    According to your description, here’s my solution.

    Total is a measure.

    Total =
    SWITCH (
        CONCATENATEX ( VALUES ( 'TableB'[Type] ), 'TableB'[Type], "," ),
        "a",
            CALCULATE (
                SUM ( 'TableA'[Value] ),
                FILTER ( 'TableA', 'TableA'[Type] IN { "a", "a+b", "a+b+c" } )
            ),
        "b",
            CALCULATE (
                SUM ( 'TableA'[Value] ),
                FILTER ( 'TableA', 'TableA'[Type] IN { "a+b", "a+b+c", "b+c" } )
            ),
        "c",
            CALCULATE (
                SUM ( 'TableA'[Value] ),
                FILTER ( 'TableA', 'TableA'[Type] IN { "a+b+c", "b+c" } )
            ),
        "a,b",
            CALCULATE (
                SUM ( 'TableA'[Value] ),
                FILTER ( 'TableA', 'TableA'[Type] IN { "a", "a+b+c", "a+b", "b+c" } )
            ),
        "b,c",
            CALCULATE (
                SUM ( 'TableA'[Value] ),
                FILTER ( 'TableA', 'TableA'[Type] IN { "a+b", "a+b+c", "b+c" } )
            ),
        "a,c",
            CALCULATE (
                SUM ( 'TableA'[Value] ),
                FILTER ( 'TableA', 'TableA'[Type] IN { "a", "a+b", "a+b+c", "b+c" } )
            ),
        "a,b,c",
            CALCULATE (
                SUM ( 'TableA'[Value] ),
                FILTER ( 'TableA', 'TableA'[Type] IN { "a", "a+b", "a+b+c", "b+c" } )
            )
    )ā€ƒ

     

    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.