Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Calculate percentage using ALLEXCEPT

Hello,

I have a bar chart as follows using Category on Axis and Segment on Legend -

 

 

 

 

 

 

 

 

 

 

 

 

 

I have following measure to calculate the SalesPercent in the graph above -

SalesPercent = DIVIDE(SUM(Orders[Sales]),CALCULATE(SUM(Orders[Sales]),ALLEXCEPT(Orders,Orders[Category])))

 

This is all fine.

 

However, when I select, lets say, 2 values out of 3 in the Segment slicer -


 

 

 

 

 

 

 

I want that the percentage should be calculated accordingly and it should sum to 100% for each category.

Instead, here is what I get -

 

 

 

 

 

 

 

 

 

 

 

 

 

Any inputs??

 

Regards

  • Hi Anonymous

     

    Please try this MEASURE

     

    SalesPercent =
    DIVIDE (
        SUM ( Orders[Sales] ),
        CALCULATE ( SUM ( Orders[Sales] ), ALLSELECTED ( Orders[Segment] ) )
    )

1 Reply

  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    Community Champion

    Hi Anonymous

     

    Please try this MEASURE

     

    SalesPercent =
    DIVIDE (
        SUM ( Orders[Sales] ),
        CALCULATE ( SUM ( Orders[Sales] ), ALLSELECTED ( Orders[Segment] ) )
    )