简体   繁体   English

Power BI - 创建度量作为视觉级别筛选器

[英]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.我有一个视觉效果作为表格,仅通过 Col D 上的 Min Number 生成 Col A 和 Col B。

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 值“A”和“B”并过滤实际数据表。

  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.我正在尝试使用AllSelected函数来解决这个问题,但它对我没有帮助。 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 .首先,它找到ColD的最小数。 Then it finds the values in ColA that are associated with that ColD value.然后它在ColA中找到与该ColD值相关联的值。 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.最后,如果表视觉对象行中的ColA值是上ColA值之一,则返回1 ,否则返回0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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