简体   繁体   中英

Power BI - Creating a measure as a Visual Level Filter

I have a requirement, where I have data like this.

ColA ColB ColC ColD
A    A     C    1 
B    C     C    1
A    B     C    3
C    D     C    2

I have one visual as a table with just Col A and Col B generated through the Min Number on Col D.

ColA ColB  
A    A     
B    c

I want to generate another visual table that takes these ColA Values "A" and "B" and filters the actual data table.

  ColA ColB ColC ColD
    A    A     C    1 
    B    C     C    1
    A    B     C    3

I am trying to solve this using AllSelected Function but it is not helping me. How can we use a measure on a visual level filter to solve this problem.

You can create a filtering measure like this:

FilterMeasure = 
    VAR MinD = CALCULATE(MIN(Table2[ColD]), ALLSELECTED(Table2))
    VAR AVals = CALCULATETABLE(VALUES(Table2[ColA]),
                    ALLSELECTED(Table2),
                    Table2[ColD] = MinD)
    RETURN IF(MAX(Table2[ColA]) IN AVals, 1, 0)

First, it finds the minimal number in ColD . Then it finds the values in ColA that are associated with that ColD value. Finally, it returns 1 if the ColA value in the row of your table visual is one of the ones from the previous step and 0 otherwise.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM