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
avou26
Frequent Visitor

Sum and Average Salary by Category

Hello! I am trying to create a visual that shows the average salary per each position type. My data set has each payment that was made over the year to each person. Is there a dax that will total the amount paid out and then average by position? 

avou26_0-1690217734801.png

 

2 ACCEPTED SOLUTIONS
v-binbinyu-msft
Community Support
Community Support

Hi @avou26 ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1690337738661.png

 

2. create measure with below dax formula

Sum Amount Per Job = SUM('Table'[Amount])
Average Per Job =
VAR cur_job =
    SELECTEDVALUE ( 'Table'[Earnings Job Description] )
VAR tmp =
    FILTER ( ALL ( 'Table' ), [Earnings Job Description] = cur_job )
VAR a =
    SUMX ( tmp, [Amount] )
VAR b =
    COUNTROWS ( CALCULATETABLE ( VALUES ( 'Table'[Employee Number] ), tmp ) )
RETURN
    DIVIDE ( a, b )

3. add a Clustered column chart with field and measure

vbinbinyumsft_1-1690337821206.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hi @avou26 

To achieve a goal I used 2 measures.

for sum :

Sum_Salary = sum('Table'[Amount])
for average 
Average+Per_employee = SUMX(values('Table'[Employee Number]),[Sum_Salary])/DISTINCTCOUNT('Table'[Employee Number])
Ritaf1983_0-1690339283679.png

Link to the sample file 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

View solution in original post

4 REPLIES 4
v-binbinyu-msft
Community Support
Community Support

Hi @avou26 ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1690337738661.png

 

2. create measure with below dax formula

Sum Amount Per Job = SUM('Table'[Amount])
Average Per Job =
VAR cur_job =
    SELECTEDVALUE ( 'Table'[Earnings Job Description] )
VAR tmp =
    FILTER ( ALL ( 'Table' ), [Earnings Job Description] = cur_job )
VAR a =
    SUMX ( tmp, [Amount] )
VAR b =
    COUNTROWS ( CALCULATETABLE ( VALUES ( 'Table'[Employee Number] ), tmp ) )
RETURN
    DIVIDE ( a, b )

3. add a Clustered column chart with field and measure

vbinbinyumsft_1-1690337821206.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ritaf1983
Super User
Super User

Hi @avou26 

If i understand you correctly

Sum of salary

Salary_by_category = sumx(values('yourtable'[earnings job description]), Sum([amount])

Average

AVG_by_category = Averagex(values('yourtable'[earnings job description]), average([amount])

if not 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Sorry about that! Thank you for your response @Ritaf1983 . Here is some sample data- i realize with my initial question that i didn't include that the employees have unique ID numbers. I would like to sum the amount per each job description category, and average it using the amount of employees(hopefully with the id number) to see what the average pay per each category is.  At the end I hope to create a bar chart visual that shows the topN paying positions in the organization based on average pay. The issue i keep running into is it is only totalling all positions and averaging based on every line, not the unique employee number

avou26_0-1690292684083.png

 

Employee NumberAmountEarnings Job Description
111831,761.20ACCOUNT CLERK
112181,761.20ACCOUNT CLERK
112181,761.20ACCOUNT CLERK
112181,761.20ACCOUNT CLERK
111831,749.25ACCOUNT CLERK
111831,736.43ACCOUNT CLERK
115611,717.10ACCOUNT CLERK
115611,717.10ACCOUNT CLERK
107382,941.96AUDITOR
107382,922.61AUDITOR
383882,904.00AUDITOR
383882,904.00AUDITOR
383882,904.00AUDITOR
48980214.90CASEWORKER
48980214.90CASEWORKER
47590214.90CASEWORKER
47590214.90CASEWORKER
47590214.90CASEWORKER
47590214.90CASEWORKER
39041214.88CASEWORKER
46927214.38CASEWORKER
47079214.38CASEWORKER
46198213.22CASEWORKER
46927213.22CASEWORKER
389071,950.10FISCAL OFFICER
498591,930.11FISCAL OFFICER
498591,792.25FISCAL OFFICER
102601,627.15FISCAL OFFICER
102601,627.15FISCAL OFFICER
498591,605.14FISCAL OFFICER
102601,603.91FISCAL OFFICER

Hi @avou26 

To achieve a goal I used 2 measures.

for sum :

Sum_Salary = sum('Table'[Amount])
for average 
Average+Per_employee = SUMX(values('Table'[Employee Number]),[Sum_Salary])/DISTINCTCOUNT('Table'[Employee Number])
Ritaf1983_0-1690339283679.png

Link to the sample file 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

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.