Percent of Total Windowed in Power BI DAX

后端 未结 2 935
北荒
北荒 2021-01-21 17:12

I have these two tables:

A data table...

ImaginaryData = 
DATATABLE (
    \"Fruit\", STRING,
    \"Colour\", STRING, 
    \"Amount\", INTEGER, 
    { 
           


        
相关标签:
2条回答
  • 2021-01-21 17:19

    The ALL function removes all filter context. Try it with ALLSELECTED instead. That will preserve your slicer selection while removing the table visual's filter context.

    If you use this (note I didn't specify a column):

    %Total = 
        DIVIDE(
            SUM( ImaginaryData[Amount] ),
            CALCULATE(
                SUM( ImaginaryData[Amount] ),
                ALLSELECTED( ImaginaryData )
            )
        )
    

    Then you should get this result:

    The reason it doesn't work if you do ALLSELECTED(ImaginaryData[Fruit]) is that the Colour filter context still exists, so you don't pick up the other fruits because those are all different colors than the row you are evaluating on.

    0 讨论(0)
  • 2021-01-21 17:28

    I used following measure and it works as expected:

    %Total = 
    CALCULATE(DIVIDE(sum(ImaginaryData[Amount]),
    CALCULATE(SUM(ImaginaryData[Amount]),ALLSELECTED(ImaginaryData))))
    
    0 讨论(0)
提交回复
热议问题