cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MARS_5676
New Member

Calculating % of total sales by function and country

Hi,

Can somebody help me please 🙂

 

I'm trying to calculate SG&A % of sales by function for every country but I'm not able to calculate it correctly. I'm using:

 

SG&A/Sales = IF(ISINSCOPE(Master[Cost Center Group]),DIVIDE(Master[SG&A],CALCULATE(Master[Sales],ALL(Master[Cost Center Group]))))
 
The data looks something like this. So I'm calculating Sales and SG&A, then when I try to divide each function SG&A by total of sales it's not working.
Cost Center FunctionCountry Account CategoryValue
F oneItalySales1222
F twoItalySG&A12
F threeFranceCost to Serve23
1 ACCEPTED SOLUTION
Eyelyn9
Community Support
Community Support

Hi @MARS_5676 ,

 

I have created a data sample:

Eyelyn9_0-1642399869691.png

So according to this: I'm trying to calculate SG&A % of sales by function for every country 

 

If the desired output is ——for Italy: = 12/ 1222  ;  for France: =15/ 67 ,please try:

Measure = 
var _sga=CALCULATE(SUM('Table'[Value]),FILTER('Table',[Country]=MAX('Table'[Country]) && [Account Category]="SG&A"))
var _all=CALCULATE(SUM('Table'[Value]),FILTER('Table',[Country]=MAX('Table'[Country]) && [Account Category]="Sales"))
RETURN DIVIDE(_sga,_all)

Eyelyn9_2-1642400177697.png

If you are still confused about it, please provide me with more details about your problem/expected output to help us clarify your scenario.

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Eyelyn9
Community Support
Community Support

Hi @MARS_5676 ,

 

I have created a data sample:

Eyelyn9_0-1642399869691.png

So according to this: I'm trying to calculate SG&A % of sales by function for every country 

 

If the desired output is ——for Italy: = 12/ 1222  ;  for France: =15/ 67 ,please try:

Measure = 
var _sga=CALCULATE(SUM('Table'[Value]),FILTER('Table',[Country]=MAX('Table'[Country]) && [Account Category]="SG&A"))
var _all=CALCULATE(SUM('Table'[Value]),FILTER('Table',[Country]=MAX('Table'[Country]) && [Account Category]="Sales"))
RETURN DIVIDE(_sga,_all)

Eyelyn9_2-1642400177697.png

If you are still confused about it, please provide me with more details about your problem/expected output to help us clarify your scenario.

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@MARS_5676 , Try a measure like

divide( calculate(sum(Table[Value]), [Account Category] = "SG&A"),calculate(sum(Table[Value]), [Account Category] = "Sales"))

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!
!! Subscribe to my youtube Channel !!

Thank you! 

Unfortunatelly it's not working, I can see only total divided by total for some reason 😞

Helpful resources

Announcements
Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!