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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
cristianjsheld
Frequent Visitor

Salary Table Vs Bonus Table Salary

Hi, 

 

I've got a table with the historical data on the salaries, with their corresponding effective date, and another with bonuses amount with their payment date. I need to create a measure/column/table (I don't know which could be the best way to do it) to know from the bonuses paid which is the percentage over salary. Something like this:

 

Salary table:

cristianjsheld_1-1663595530417.png

Bonus table:

cristianjsheld_0-1663595501063.png

 

The logic should work from the bonus amount relating to the payment date and the compensation effective date, where the bonus will be calculated over the latest salary based on the date (the bonus paid on 02/15/2020 will be calculated over the salary with a compensation date 07/01/2019 as it was the latest salary prior the bonus payment date). I have a calendar table where the payment date and the compensation date are connected.

 

EmployeePayment dateDiscretionary Bonus AmountBase Salary Date Pay Rate Percentage from salary
4152/15/202039007/1/2019         156,0002.50%
4152/15/202120007/1/2019         156,0001.28%
4152/15/202260001/1/2022         165,0003.64%

 

Thanks!

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@cristianjsheld Maybe:

Measure =
  VAR __Employee = MAX('Bonus'[Employe #])
  VAR __Bonus = MAX('Bonus'[Bonus Amount])
  VAR __PayDate = MAX('Bonus'[Payment Date])
  VAR __LastCompDate = MAXX(FILTER(ALL('Salary'),'Salary'[Employee #] = __Employee && 'Salary'[Compensation: Date] <= __PayDate), 'Salary'[Compensation: Date])
  VAR __PayRate = MAXX(FILTER(ALL('Salary'), 'Salary'[Employee #] = __Employee && 'Salary'[Compensation: Date] = __LastCompDate ), 'Salary'[Pay rate])
RETURN
  DIVIDE(__Bonus, __PayRate,0)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
cristianjsheld
Frequent Visitor

Amazing @Greg_Deckler . It worked on the first try.

@cristianjsheld Kudo's to you for providing a clear explanation, sample data and expected output! Helps soooooooo much!!



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Super User
Super User

@cristianjsheld Maybe:

Measure =
  VAR __Employee = MAX('Bonus'[Employe #])
  VAR __Bonus = MAX('Bonus'[Bonus Amount])
  VAR __PayDate = MAX('Bonus'[Payment Date])
  VAR __LastCompDate = MAXX(FILTER(ALL('Salary'),'Salary'[Employee #] = __Employee && 'Salary'[Compensation: Date] <= __PayDate), 'Salary'[Compensation: Date])
  VAR __PayRate = MAXX(FILTER(ALL('Salary'), 'Salary'[Employee #] = __Employee && 'Salary'[Compensation: Date] = __LastCompDate ), 'Salary'[Pay rate])
RETURN
  DIVIDE(__Bonus, __PayRate,0)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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