cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

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:

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
Super User

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

Proud to be a Super User!

6 REPLIES 6
Solution Sage

Hope this helps:

Super User

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

Proud to be a Super User!

Helper II

Hello,

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

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
Super User

there is a small changes in the formula. Can you modify and try this formula now?

)

``````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

Proud to be a Super User!

Helper II

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?

Super User

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

Proud to be a Super User!

Announcements

#### Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

#### Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors