Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
v-eqin-msft
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
v-eqin-msft
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"))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Thank you! 

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.