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
GaryD
Regular Visitor

Using VALUES vs SUM to calculate commission

Hi - having an issue when using a commission table where the % differs based on Facility and sales rep. I'm using a filter by the sales rep to get just thier sales so I can print this out.

 

I started using SUM but the subtotal then shows all the commissions and not for the selected -

Com ($) using SUM = [Gross Proft] * SUM(tbl_SaleRep[% Commission])
 
Changed to use VALUES which fixed the subtotals but then if a sales person has different % I get an error -
Com ($) using VALUES = [Gross Proft] * VALUES(tbl_SaleRep[% Commission])
 
Screenshots below:
RelationshipRelationship
Paul - diff %Paul - diff %
Peter - same %Peter - same %
 

Ideally what I need is to call the % based on Facilty and Name when the Name is filtered, but unable to figure this out and have not been able to find in the community.

 

Thanks in advance,

Gary

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

This measure works:

 

Commission = SUMX(SalesRep, [Profit]* [% Commission])

 

where 

Profit = SUM (Sales [Profit])

and

% Commission = SUM( SalesRep [% Commission])

Or to make it simple

Commission = SUMX (SalesRep, CALCULATE(SUM(Sales [Profit])) * CALCULATE(SUM(SalesRep[% Commission]))

and 

% Commission = IF(ISINSCOPE(SalesRep[Names]), SUM(SalesRep[% Commission]), DIVIDE([Commission], [Profit]))

 

 

Gross Profit.jpg

 

I've attached the sample PBIX file 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

8 REPLIES 8
PaulDBrown
Community Champion
Community Champion

Can you share some sample data?

You probaly need a measure along the lines of:

Com($) =
SUMX (
ADDCOLUMNS (
SUMMARIZE ( tbl_SalesRep, 'tbl_SalesRep'[Facility], 'tbl_SalesRep'[Names] ),
"Com", [Gross Profit] * SUM ( 'tbl_SalesRep'[% Comission] )
),
[Com]
)

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Added the tables below, would have shared the PowerBI file but not comfortable sharing via OneDrive from work

 

SaleRep Table:

 

FacilityNames% Commission
Fac1Peter5%
Fac2Peter5%
Fac3Paul5%
Fac4Paul10%

 

Sales Table:

 

FacilitySales IDCountryAmountCostGross Profit
Fac11234C110-55
Fac11235C212-57
Fac11236C110-55
Fac21237C110-55
Fac21238C110-55
Fac21239C212-57
Fac21240C212-57
Fac31241C110-55
Fac41242C110-55
Fac41243C110-55
Fac41244C212-57
Fac41245C212-57
Fac41246C212-57
Fac41247C110-55

 

Visual these create (note: previous visuals added Costs and not minus them):

 

GaryD_0-1645387026237.png

 

GaryD
Regular Visitor

My Gross Profit is a measure in PowerBI but I added the field in the table - that might make it slightly different

PaulDBrown
Community Champion
Community Champion

This measure works:

 

Commission = SUMX(SalesRep, [Profit]* [% Commission])

 

where 

Profit = SUM (Sales [Profit])

and

% Commission = SUM( SalesRep [% Commission])

Or to make it simple

Commission = SUMX (SalesRep, CALCULATE(SUM(Sales [Profit])) * CALCULATE(SUM(SalesRep[% Commission]))

and 

% Commission = IF(ISINSCOPE(SalesRep[Names]), SUM(SalesRep[% Commission]), DIVIDE([Commission], [Profit]))

 

 

Gross Profit.jpg

 

I've attached the sample PBIX file 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Thanks Paul, and apologies for the delay...new job!

 

The ISINSCOPE worked a treat and loved how you seperate the measures in a new table!

PaulDBrown
Community Champion
Community Champion

New job hey? Congratulations!!





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






PaulDBrown
Community Champion
Community Champion

Try:

Com ($) using SUM =
SUMX ( tbl_SaleRep, [Gross Proft] * SUM ( tbl_SaleRep[% Commission] ) )




Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Thanks for the reply. Still not fixed. That works the same as -

 

Com ($) using SUM = [Gross Proft] * SUM(tbl_SaleRep[% Commission])

 

Problem I have with both of those is the subtotal does not equal the sum of the individual rows (below should be 15.90 not 55.50). Only way the subtotals work is with VALUES but then % commission needs to be the same. 

 

GaryD_0-1645383257188.png

 

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.