过滤测量似乎不起作用 [英] Filtered Measure seemingly not working

查看:27
本文介绍了过滤测量似乎不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这些数据:

那么我有这个水果甜甜圈:

Then I have this donut of fruit:

我有这个措施来挑选上面甜甜圈中选择了哪些水果:

I have this measure to pick-up which fruit has been selected in the above donut:

Selected Fruit = SELECTEDVALUE( Fruit[Fruit] )

它似乎工作正常,例如如果我将此度量添加到卡片并单击梨:

It seems to work fine e.g. if I add this measure to a card and click Pear:

现在问题来了 - 我有一个条形图必须关闭交互,但仍需要通过在甜甜圈中选择的内容进行过滤 - 所以我创建了这个度量:

Now comes the problem - I have a bar chart which has to have interactions turned off but still needs to be filtered by what has been selected in the donut - so I created this measure:

Value Filtered = 
CALCULATE(
    SUM(Fruit[Value])
    ,FILTER(
        Fruit
        ,Fruit[Fruit] = [Selected Fruit]
    )
)

但是现在当我单击 Pear 时,它会更改卡片中的文本但对图表没有影响 - 我做错了什么?

But now when I click Pear it changes the text in the card but has no impact on the chart - what am I doing wrong?

请注意,如果我将 DAX 更改为以下内容,则它可以工作:

Please note that if I change the DAX to the following then it works:

Value Filtered = 
    CALCULATE(
        SUM(Fruit[Value])
        ,FILTER(
            Fruit
            ,Fruit[Fruit] = "Pear"
        )
    )

<小时>

编辑

@RADO 建议了以下两种方法,但都不适合我:

@RADO suggested the following two approaches but neither works for me:

Value Filtered = 
VAR Selected_Fruit = [Selected Fruit]
RETURN
    CALCULATE(
        SUM(Fruit[Value])
        ,FILTER(
            Fruit
            ,Fruit[Fruit] = Selected_Fruit
        )
    )


Value Filtered = 
VAR Selected_Fruit = [Selected Fruit]
RETURN
    CALCULATE(
       SUM(Fruit[Value]),
       Fruit[Fruit] = Selected_Fruit
    )

我同意这个问题一定与计算中的上下文重新计算有关.我不明白为什么这种使用变量的方法对我不起作用!

I do agree that the problem must be something to do with re-calculation of the context within the calculation. I don't understand why this approach using a variable is not working for me!

推荐答案

您正在尝试过滤而不是同时过滤.你不能两全其美.当您关闭交互时,条形图无法响应圆环图中发生的任何事情,因为您已将其从过滤器上下文中删除.无论您在度量中写入什么内容,您都无法访问选择同时禁用交互.

You are trying to filter and not filter at the same time. You can't have it both ways. When you turn off interaction, the bar chart cannot respond to anything that happens in the donut chart since you've removed it from the filter context. It doesn't matter what you write in your measure, you can't access selections while simultaneously disabling interaction.

也就是说,我确信您的原始问题可以得到解决.我建议制作一个包含日期元素的最小示例,并发布一个更全面地解释该问题的问题.

That said, I'm sure your original problem can be solved. I'd suggest cooking up a minimal example with the date element included and posting a question that explains that question more fully.

这篇关于过滤测量似乎不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆