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
spacegurl
New Member

Avg. Past 3 Month Sales based on Selected Month

Hi!

 

I want to create a measure that calculates the average of the past 3 months sales based on selected months.

For example :

MonthsSales
Jan1203
Feb2389
Mar3957
Apr4850
May1637
Jun9473
Jul4749
Aug4846
Sep4759
Oct2484
Nov4748
Dec7829

 

If the selected month is 'July', then the measure output will be:

(sales jun + sales may + sales april) / 3 = (9473 + 1637 + 4850) / 3 = 5320.

 

Please help, thank you!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @spacegurl ,

We can use dates in period wrapped in a calculate function to create the desired output.

Avg3months =
CALCULATE (
    AVERAGE ( Sheet1[Sales] ),
    DATESINPERIOD ( Sheet1[Months], LASTDATE ( Sheet1[Months] ), -3, MONTH )
)

 
Desired Output:

Dax_Noob_0-1661838765507.png


Hope that helps 🙂

View solution in original post

2 REPLIES 2
v-henryk-mstf
Community Support
Community Support

Hi @spacegurl ,

 

Whether the advice given by @Anonymous  has solved your confusion, if the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out.


Looking forward to your feedback.


Best Regards,
Henry

Anonymous
Not applicable

Hi @spacegurl ,

We can use dates in period wrapped in a calculate function to create the desired output.

Avg3months =
CALCULATE (
    AVERAGE ( Sheet1[Sales] ),
    DATESINPERIOD ( Sheet1[Months], LASTDATE ( Sheet1[Months] ), -3, MONTH )
)

 
Desired Output:

Dax_Noob_0-1661838765507.png


Hope that helps 🙂

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.