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
Daniel_B
Helper II
Helper II

Calculate Average Measure for Current, Previous and Month Before

Hi Everyone

 

I've tried to create a measure which calculates an average score for the current month (based on the latest data), previous month and the month before but the average is not correct as I manually checked it against the source data

 

My data is dummy data for testing which has;

 

2 years of data (2018 and 2019) 

240 rows (10 for each month)

Each month shows the date format as dd/mm/yyyy (example 01/01/2018, 01/02/2018 etc) and is formatted in Power BI as "Date"

 

The measure I tried is below

 

Current Recommend Score = (CALCULATE
(AVERAGE(Data[RecommendScore]),FILTER(Data,MONTH(Data[Date])=MONTH(TODAY()))))
 
As my current month didn't work, there's no reason why any attempts at the previous 2 months would yield better results
 
Ideally, I would also like to include a conditional format to compare the months to one another showing an up, down or neutral arrow if they are up, down or the same respectively.. I have something different on another report where if latest month > previous month then 1 else 0 (see below) and I've tried to replicate it but again to no avail
 
Met/Not Met = IF([MTD Postive]>[LM Positive],1,0)
 
Any ideas on what I'm doing wrong?
 
Thanks

Dan_B
1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @Daniel_B ,

 

If your dates are not consecutive, you can create a calendar table.Then create a measure to calculate the average value of the last three months, and use the newly created calendar as the slicer.You can refer to the pbix.

test_last_3_month.PNG

 

Best Regards,

Liang

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

2 REPLIES 2
V-lianl-msft
Community Support
Community Support

Hi @Daniel_B ,

 

If your dates are not consecutive, you can create a calendar table.Then create a measure to calculate the average value of the last three months, and use the newly created calendar as the slicer.You can refer to the pbix.

test_last_3_month.PNG

 

Best Regards,

Liang

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

Daniel_B
Helper II
Helper II

If possible, I'd like to learn how to make it so that if there is a calendar page filter that the user can choose the year and month and the data still show a comparison of the selected month in the selected year

 

Otherwise, just being able to see the latest 3 comparable months would be great

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.