cancel
Showing results for
Did you mean:

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

Frequent Visitor

## How to get maximum salary, name of employee with maximum salary and department in power bi

Hey, I am new to power bi, and still learning. I want to know how to get maximum salary, name of employee with maximum salary and department in power bi? I want to show the data in tabular form.

1 ACCEPTED SOLUTION
Super User

Hi Have corrected the measure try this one:

MaxSalaryName =
CALCULATE (
MAX ( 'Sheet5'[Name] ),
FILTER (
'Sheet5',
'Sheet5'[Salary] = MAX ( 'Sheet5'[Salary] )
)
) and
max salary = MAX(Sheet5[Salary])
here is my output hope this should work

Regards

7 REPLIES 7
Super User

Based on input data here is my approach to finding max salary and name for a given department

you need to create two measure:

1. max salary = MAX(Sheet4[Salary])

MaxSalaryName =
CALCULATE(
MAX('Sheet4'[Name]),
FILTER(
'Sheet4',
'Sheet4'[Salary] = [max salary]
)
)
this is my output

Check for more intersing solution here: https://www.youtube.com/@letssolveproblem

Regards

Frequent Visitor

I tried this code, but the name which is being returned is the last name available for that dept.
So if the data goes like this:

 Name Dept Salary A 1 3500 B 1 4300 C 1 2200 D 2 1200 E 2 3240 F 3 6300 G 3 2319 H 3 1200

then the output should be

 Name Dept Salary B 1 4300 E 2 3240 F 3 6300

But using the measure/query provided by you. It is returning

 Name Dept Salary C 1 4300 E 2 3240 H 3 8200
Super User

Hi Have corrected the measure try this one:

MaxSalaryName =
CALCULATE (
MAX ( 'Sheet5'[Name] ),
FILTER (
'Sheet5',
'Sheet5'[Salary] = MAX ( 'Sheet5'[Salary] )
)
) and
max salary = MAX(Sheet5[Salary])
here is my output hope this should work

Regards

Frequent Visitor

Heyy, This WORKED! Thanks alot! Big Help!

Super User

Please supply some data and an example of the desired result.

Phil

If I helped you, click on the Thumbs Up to give Kudos.

Proud to be a Super User!

Frequent Visitor

Hey Phil, Thanks for replying. As the data is quite huge, below is a dummy data.

 Name Dept Salary A 1 3500 B 1 2200 C 1 4300 D 2 1200 E 2 3240 F 3 6300 G 3 2319 H 3 8200

I want the below desired output.

 Name Dept Salary C 1 4300 E 2 3240 H 3 8200
Super User

Hi,

These measures work

Max salary = MAX(Data[Salary])
Highest earner = CALCULATE(MAX(Data[Name]),FILTER(Data,Data[Salary]=[Max salary]))

Hope this helps.

Regards,
Ashish Mathur
http://www.ashishmathur.com

Announcements

#### Fabric certifications survey

Certification feedback opportunity for the community.

#### Power BI Monthly Update - April 2024

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

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors