筛选后的措施似乎无效 [英] Filtered Measure seemingly not working

查看:92
本文介绍了筛选后的措施似乎无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下数据:

然后,我得到了这个水果甜甜圈:

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"
        )
    )






EDIT


EDIT

@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.

这就是说,我敢肯定您最初的问题可能是解决了。我建议准备一个包含date元素的最小示例,并发布一个问题来更全面地解释该问题。

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天全站免登陆