cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
newbie9292
Helper II
Helper II

% share of the total sales for each month

Hello, 

I want to calculate the % share of each months sale over the total sale for each year in the following visual: 

newbie9292_0-1676977181068.png

 

So for example the total sales for the year 2020 was 479.39 M.
Hence January months' share towards the total sale in 2020 would be : 6.90%.

 

Can someone help me?

 

1 ACCEPTED SOLUTION

@newbie9292 ,

add that category column in the allexcept, check the below

Sales % = 
VAR _sumOfSales = SUM(Sales[Sales])
VAR _totalSales = CALCULATE(
    SUM(financials[ Sales]),ALLEXCEPT(financials,financials[Year],financials[Segment]))
VAR _result = DIVIDE([Sum of Sales],_totalSales)
RETURN _result

Thanks,

Arul

Regards,
Arul
If I answered your question kindly mark my post as a solution and a kudo would be appreciated.

View solution in original post

6 REPLIES 6
Padycosmos
Solution Sage
Solution Sage

Hope this helps:

Padycosmos_0-1676981959001.png

 

Arul
Super User
Super User

@newbie9292 ,

modify this based on your need and try,

Sales % = 
VAR _sumOfSales = SUM(Sales[Sales])
VAR _totalSales = CALCULATE(
    SUM(financials[ Sales]),ALL(financials))
VAR _result = DIVIDE([Sum of Sales],_totalSales)
RETURN _result

Thanks,

Arul

Regards,
Arul
If I answered your question kindly mark my post as a solution and a kudo would be appreciated.

Hello,

Thanks for your reply. But I am not getting the correct output with this measure.

newbie9292_0-1676980600682.png


For example the % share for January 2020 should have been 6.9% but its coming to be 2.34% with your measure.

Sales % =
VAR _sumOfSales = SUM('MyTable'[AuftrEing])
VAR _totalSales = CALCULATE(
    SUM('MyTable'[AuftrEing]),ALL('MyTable'))
VAR _result = DIVIDE(_sumOfSales,_totalSales)
RETURN _result

@newbie9292 ,

there is a small changes in the formula. Can you modify and try this formula now?
Instead of ALL use ALLEXCEPT('MyTable',MyTable[Year])

)

Sales % = 
VAR _sumOfSales = SUM(Sales[Sales])
VAR _totalSales = CALCULATE(
    SUM(financials[ Sales]),ALLEXCEPT(financials,financials[Year]))
VAR _result = DIVIDE([Sum of Sales],_totalSales)
RETURN _result

Thanks,

Arul

Regards,
Arul
If I answered your question kindly mark my post as a solution and a kudo would be appreciated.

Hello @Arul 

Thanks again for your solution its working only with one exception. I have a page level categorical filter. And when I select a category in that filter it doesn't gets applied to the measure. How to handle that?

@newbie9292 ,

add that category column in the allexcept, check the below

Sales % = 
VAR _sumOfSales = SUM(Sales[Sales])
VAR _totalSales = CALCULATE(
    SUM(financials[ Sales]),ALLEXCEPT(financials,financials[Year],financials[Segment]))
VAR _result = DIVIDE([Sum of Sales],_totalSales)
RETURN _result

Thanks,

Arul

Regards,
Arul
If I answered your question kindly mark my post as a solution and a kudo would be appreciated.

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors