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
ashishshahs
New Member

Calculate and Lookup values from Static Table

Greetings All,

 

I have a data model, that stores NetMargin Amount, Sales Person, Customer per week. So, in short, have multiple values for the year (52 weeks). I have a need to calculate the commission for the Sales Person based on 1) weekly sales commission (irrespective of customer), 2) Quarterly Sales Commission. The commission is stored in a separate table with tiers e.g;

0-150 = 1.5%

151- 450 = 2% and so on.

 

I tried the LOOKUPVALUE function but it did not lookup in the static standalone commission table. Not sure why it does not bring up the values. Any guidance is appreciated.

 

-Ashish

 

2 ACCEPTED SOLUTIONS

@ashishshahs , Try a measure like

 

sumx(summzarize(Table, Table[Customer], Table[Week], "_1", calculate(sumx(filter(Table, [margin Sum] >=min(commission[Lower]) && [margin Sum] <=max(commission[Upper])), [margin Sum]*max(commission[Commission])))),[_1])

View solution in original post

v-jayw-msft
Community Support
Community Support

Hi @ashishshahs ,

 

Check the formula below.

Column = 
var summargin = CALCULATE(SUM('Sales'[Margin]),ALLEXCEPT('Sales','Sales'[Week],'Sales'[Sales]))
var commiss = CALCULATE(MAX('commission'[Commission]),FILTER('commission','Sales'[Margin]>'commission'[Lower]&&'Sales'[Margin]<='commission'[Upper]))
return
summargin*commiss

Result would be shown as below.

1.PNG 

 

Best Regards,

jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

4 REPLIES 4
v-jayw-msft
Community Support
Community Support

Hi @ashishshahs ,

 

Check the formula below.

Column = 
var summargin = CALCULATE(SUM('Sales'[Margin]),ALLEXCEPT('Sales','Sales'[Week],'Sales'[Sales]))
var commiss = CALCULATE(MAX('commission'[Commission]),FILTER('commission','Sales'[Margin]>'commission'[Lower]&&'Sales'[Margin]<='commission'[Upper]))
return
summargin*commiss

Result would be shown as below.

1.PNG 

 

Best Regards,

jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
amitchandak
Super User
Super User

@ashishshahs ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

 

Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.

Hello Amit,

 

Thanks for your response. The Sales Table loks something like the below ...

CustomerWeekMarginSales
Customer 1132.0155John Perry
Customer 212.716Chuck Jones
Customer 327.15Chuck Jones
Customer 222.716Chuck Jones
Customer 222.716Chuck Jones
Customer 222.716Chuck Jones
Customer 337.15Chuck Jones
Customer 1332.0155John Perry
Customer 1332.0155John Perry
Customer 1332.0155John Perry

 

The commission table looks something like ... 

 
Net Margin in $LowerUpperCommission
0-15001500.015
151-4501504500.02
451-6504506500.03
651-8506508500.04
851-100085010000.045
1001-1200100012000.05
1200+120050000.06
 

 

 

Example: John Perry, for Week 3, the total of his margin is 96.05 and his commission should be 96.05*0.015.

 

-Ashish

 

@ashishshahs , Try a measure like

 

sumx(summzarize(Table, Table[Customer], Table[Week], "_1", calculate(sumx(filter(Table, [margin Sum] >=min(commission[Lower]) && [margin Sum] <=max(commission[Upper])), [margin Sum]*max(commission[Commission])))),[_1])

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.