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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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"))

Thank you! 

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.