Forum Discussion

marcusvmc's avatar
marcusvmc
Frequent Visitor
8 years ago
Solved

Filter table based on two columns

Hi everyone,   I have a huge table which is simplified below. I need to select a month in a slicer and filter 2 columns in that table, meaning that the filtered table needs to contain entries with...
  • v-huizhn-msft's avatar
    8 years ago

    Hi marcusvmc,

    Please follow the steps below and get expected result. I named your sample table as 'Test1'

    1. Create a new table including unique month value by type the formula.

    Month =
    DISTINCT (
        UNION (
            SELECTCOLUMNS ( Test1, "Month", Test1[Month 1] ),
            SELECTCOLUMNS ( Test1, "Month", Test1[Month 2] )
        )
    )
    


    You will get the Month table, please note don't create relationship betweem the Month table and your fact table.

    Month
    2. Create two measures to get Month1, Month2 columns using the formulas.

    Month1 = CALCULATE(VALUES(Test1[Month 1]),FILTER(Test1,Test1[Month 1]=SELECTEDVALUE('Month'[Month])))
    
    Month2 = CALCULATE(VALUES(Test1[Month 2]),FILTER(Test1,Test1[Month 2]=SELECTEDVALUE('Month'[Month])))


    3. Create a table visual to display all rows including selected month in Month1, Month2. Create a measure to filter the table, add it as visual level filter, please see the screenshot shown.

    Filter = IF(Test1[Month1]||Test1[Month2],1,0)

    Add measure [filter] as visual level filter
    4. Finally, you will get expected result as follows. You can download the.pbix file for more details.

     

    Best Regards,
    Angelia