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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Syndicate_Admin
Administrator
Administrator

[Help] Problem when plotting calculations.

Hello everyone!

Thank you for your answers.

I have a problem when graphing... I have used different methods of calculating averages but I do not find the solution. If I extend the X axis from the beginning my problem is solved, it is only at the time of filtering with the X axis.

In my X axis I have sales from 2017 onwards, but through filters I want to show the last year, however, when filtering the graph, this considers me the first sale on the first date and not the previous sales, showing me the average only with the value of the first date, but in my data if I have past information. How could I fix it? And so I take the months before the filter?

I have used several codes and the one I use now is as follows:

AVERAGEX(
DATESINPERIOD('Calendar Table'[Date],Max('Calendar Table'[Date]),-3,MONTH),
CALCULATE(SUM('Sales'[Sales]),REMOVEFILTERS('Calendar Table'[Month-Year]))
)

Currently it is in this way, the first two months are wrong.

ErróneoErróneoErroneous

This is how the graph should be, taking the past information and showing the average of the last 3 months in the current graph.

Así debería serAsí debería serThat's how it should be.

Anyone with any possible solution?

1 REPLY 1
DataInsights
Super User
Super User

@Jean_D,

 

I believe the issue is that your date filter which starts at Q1 2021 is excluding the months in 2020 that you need for the three-month average. The article below provides a solution that you may be able to adapt:

 

https://www.sqlbi.com/articles/show-previous-6-months-of-data-from-single-slicer-selection/ 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.