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
Sofinobi
Helper IV
Helper IV

total sales for last 3 months

hi all,

i'm trying to calculate the total sales for (running) last 3 months (i have already calculated the total sales for all periode "total sales")

ex; we are o december, i need the sales for november, october and septembre.

 

thank you for your help

1 ACCEPTED SOLUTION

@Sofinobi 

This might work: put the months in the visual and put KEEPFILTERS in the formula.

total sales last 3 months =
CALCULATE (
    [total sales],
    KEEPFILTERS (
        DATESINPERIOD ( d_date[date], EOMONTH ( MAX ( d_date[date] ), - 1 ), -3, MONTH )
    )
)

View solution in original post

9 REPLIES 9
Sofinobi
Helper IV
Helper IV

thank you for you answers,
@FreemanZ  i want to add a visualisation of the 3 last months (in a matrix or line chart) without filtering dates everytime when month change.

@Barthel thank you for your help, 
your measure calculate the sum of the 3 months, when i put it in a matrix it doesn't show me the 3 months separately.

@Sofinobi 

Yes, this measure shows the value of the three months aggregated. If you want to show the value spread over the three months you will have to work with a disconnected date table. This is a good video explaining how to create something like this. 

https://www.youtube.com/watch?v=d8Rm7dwM6gc

Barthel's solution shall work, if you plot with d_date[date]. Or what error do you get?

i dont get an error with that measure, but i get the sum of the 3 months

can you make some screenshot?

exem.PNG

@Sofinobi 

This might work: put the months in the visual and put KEEPFILTERS in the formula.

total sales last 3 months =
CALCULATE (
    [total sales],
    KEEPFILTERS (
        DATESINPERIOD ( d_date[date], EOMONTH ( MAX ( d_date[date] ), - 1 ), -3, MONTH )
    )
)
FreemanZ
Super User
Super User

that depends very much on how you are going to present it or the filter context (what columns you have in your visual, date column? month column?)

Barthel
Solution Sage
Solution Sage

Hey @Sofinobi,
Use this formula, assuming you have a date table ('d_date') with a date column ('[date]'):

total sales last 3 months =
CALCULATE (
    [total sales],
    DATESINPERIOD ( d_date[date], EOMONTH ( MAX ( d_date[date] ), - 1 ), -3, MONTH )
)

 

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.