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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
Anonymous
Not applicable

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)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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?

Anonymous
Not applicable

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 @Anonymous  !!
I'm sorry but I don't understand this. Could you explain?

var _a = 'table'[avg]

 

Anonymous
Not applicable

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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