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

Average Last 6 months accumulated

Hello dear community, I come to you so that you can help me with this DAX calculation.

 

I need a Calculated Column to show me:

  • the average of the last 6 months accumulated for each collaborator (in case the collaborator appears> = 6 times in the year);
  • or in the event that the employee in the current year period appears less than 6 months, showing the average based on the number of months that the employee has been in the company in the current period, for example:
Year Filter: 2021
Current month: May2021 (5)
Seniority of the collaborator to May2021: 3 months (that is, the collaborator appears 3 times until May,
if in June it becomes active, the collaborator when we are in June then it will appear 4 times, and so on)

So the average will be = (Mar + Apr + May) / 3

Also consider that I already have a calendar table in my Power BI.

 

Here I have an example sample of what I want exactly (column "Average Last 6 months), you can download the file here:

I also leave the extract here:

Reyesnes_0-1623936664281.png

I read them, I hope they can help me as soon as possible. and thank you very much in advance.

 

Nestor Reyes

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

AVG 6M = 
CALCULATE(
    AVERAGEX( DATA, DATA[Compensation] ),
    DATESINPERIOD( DATA[Date], MAX( DATA[Date] ), -6, MONTH )
)

Screenshot 2021-06-17 204335.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Muchas gracias @CNENFRNL 

CNENFRNL
Community Champion
Community Champion

AVG 6M = 
CALCULATE(
    AVERAGEX( DATA, DATA[Compensation] ),
    DATESINPERIOD( DATA[Date], MAX( DATA[Date] ), -6, MONTH )
)

Screenshot 2021-06-17 204335.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors