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
pedroccamaraDBI
Post Partisan
Post Partisan

Average monthly salary by employee

Hello everyone

As you all know, the salary is a set of codes for each month and person, right? Like the salary, food allowance, productivity allowance, etc.
I would like to know the average of the salary only for each person, each month, of a particular year.  And this measeure would work if every month had values, which it does not.

 

Avg salary By Year & Employee =
AVERAGEX(
    VALUES( 'Dates'[MonthOfYear]),
    AVERAGEX(
        VALUES( 'Employee'[WorkerName] ),
        [Salary]))               (this measure is a simple one that calculates a sum of a value filtered by the code of the salary name)
 
As an example, this worker have worked for 8 months in 2021 but only 3 months had values in the salary item. The other 5 months had values in other items diffferent than salary.
Capture.JPG
It's showing me the average of 540 but it should be 1440.
Could you please help me?
Thanks in advance
1 ACCEPTED SOLUTION

Hi @pedroccamaraDBI ,

var _a = 'table'[avg]

This is the measure you created before.

I have created a simple sample , please refer to it to see if it helps you.

vpollymsft_0-1672190680278.png

 

 Best Regards
Community Support Team _ Polly

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

5 REPLIES 5
amitchandak
Super User
Super User

@pedroccamaraDBI , Try like

Avg salary By Year & Employee =
var _calc = AVERAGEX(
VALUES( 'Employee'[WorkerName] ),
[Salary])
return
AVERAGEX(filter(
VALUES( 'Dates'[MonthOfYear]) , _calc <> 0 ),_calc)

Hello @amitchandak 
Thank you for your answer.
I think you've manage to filter the non salary values,
Capture.JPG
But instead of the average it's showing the total.
I thought it would be enough to replace the VALUES function but not. 
Can you still help me?

Hi @pedroccamaraDBI ,

Please have a try.

Create a measure.

measure== var _a = 'table'[avg]
var _b = SUMMARIZE('table','table'[date],"aaa",'table'[avg])
return
IF(HASONEVALUE('table'[date]),_a,averagex(_b,[aaa]))

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

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

Hello @v-rongtiep-msft  !!
I'm sorry but I don't understand this. Could you explain?

var _a = 'table'[avg]

 

Hi @pedroccamaraDBI ,

var _a = 'table'[avg]

This is the measure you created before.

I have created a simple sample , please refer to it to see if it helps you.

vpollymsft_0-1672190680278.png

 

 Best Regards
Community Support Team _ Polly

If this post helps, then please consider Accept 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.

Top Solution Authors