Filtered Measure seemingly not working

时光总嘲笑我的痴心妄想 提交于 2020-01-05 05:32:05

问题


I have this data:

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

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?

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

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


回答1:


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.



来源:https://stackoverflow.com/questions/51340963/filtered-measure-seemingly-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!