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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.