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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
GJ217
Resolver III
Resolver III

Calculating the Latest Salary for Salary Banding

Hi,

 

I need to calculate the latest salary for Active and Inactive employees in order to present them in Salary Bands.

 

I have a Person table which lists the employment start and end date for each employee. I also have a Salary table which lists the salaries for each person for each year there was a change (increase or decrease) and this table has a SalaryFromDate and a SalaryToDate.

 

The Salary table is linked to the Person table via the Person Number in a many to many relationship (this is because we have many employees who leave and come back).

 

How do I get the latest Salary for both Active employees and Inactive employees?

 

Any and all suggestions with this is much appreciated.

 

 

1 ACCEPTED SOLUTION

Hi @GJ217 ,

 

Please try:

Measure = 
VAR _max_date = MAX('Salary Table'[SalaryFromDate])
VAR _salary = CALCULATE(MAX('Salary Table'[salaries]),'Salary Table'[SalaryFromDate]>=_max_date) 
RETURN
_salary

If this does not work, please feel free to contact me and preferably with expected output.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

4 REPLIES 4
v-cgao-msft
Community Support
Community Support

Hi @GJ217 ,

 

Suppose we have:

Person Table

vcgaomsft_0-1671783521666.png

Salary Table

vcgaomsft_1-1671783550280.png

Relationships

vcgaomsft_2-1671783594435.png

Please  try this:

Measure = 
VAR _max_start_date = MAX('Person Table'[start date])
VAR _salary = CALCULATE(SUM('Salary Table'[salaries]),'Salary Table'[SalaryFromDate]>=_max_start_date) 
RETURN
_salary

Result:

vcgaomsft_3-1671783631889.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Hi @v-cgao-msft 

 

Thanks for getting back to me on this. The measure totals up the salaries an employee has had in my visual and my tables are joined in the same way as your sample. 

 

I think the SUM('Salary Table'[salaries]), part of the measure is totaling up all the salaries.

 

Is there a way to tweak this measure to bring back the lastest salary?

 

 

Hi @GJ217 ,

 

Please try:

Measure = 
VAR _max_date = MAX('Salary Table'[SalaryFromDate])
VAR _salary = CALCULATE(MAX('Salary Table'[salaries]),'Salary Table'[SalaryFromDate]>=_max_date) 
RETURN
_salary

If this does not work, please feel free to contact me and preferably with expected output.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

@v-cgao-msft   this works, thank you very much.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.