The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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
Solved! Go to Solution.
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 )
)
)
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.
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.
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?
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 )
)
)
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?)
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 )
)
User | Count |
---|---|
25 | |
12 | |
8 | |
8 | |
7 |
User | Count |
---|---|
28 | |
13 | |
12 | |
12 | |
6 |