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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Calculate sum of past 3 months

Hi All,

 

Please help me in this issue. I have a month slicer where I can select only one month. I would like to create a measure (onto a card visual), which shows me the sum amount from the past 2 month + the selected month. So if I choose 2019 June, I want to see the sum of amounts from 2019 April, May and June! I use now the following measure but it shows me only the selected month's amount..:

CALCULATE(sum(GLEntry[Amount]);GLEntry;GLEntry[New Main Group] = "Net Sales";DATESINPERIOD('Date'[Date];LASTDATE('Date'[Date]);-2;MONTH))
 
Does anybody has an idea what can be the problem?
Many thanks in advance!
Mate

 

5 REPLIES 5
tex628
Community Champion
Community Champion

I believe this should work for you.

Measure =
VAR period = DATESINPERIOD('Date'[Date];LASTDATE('Date'[Date]);-2;MONTH)
CALCULATE(
sum(GLEntry[Amount]);
ALL('Date');
GLEntry[New Main Group] = "Net Sales";
Period
)

Connect on LinkedIn
Anonymous
Not applicable

Hi @tex628 ,

 

Many thanks it worked!

One more question please, it's the same issue but with one more difficulty..

I try the following measure: 

var period = DATESINPERIOD('Date'[Date];LASTDATE('Date'[Date]);-3;MONTH)
var result1 = CALCULATE([Sales until Last Month2]; ALL('Date'[Date]); GLEntry[GL Account No_ new] in {x;y;z};period)
return
result1
 
Where the [Sales until Last Month2] is another measure:
Sales until Last Month2 = CALCULATE(sum(GLEntry[Amount]);FILTER(ALL('Date'[Date]);'Date'[Date] < min('Date'[Date])))+[Sales (selected month)]
 
Which shows us a balance, the total sales until the last month. And this is waht I want to put into the measure you helped me to write. But if I just put it into the Calculate function it will shows me only the balance at the selected month (on the slicer). But I want to show me the sum of last 3 month Balance not just the selected!
 
Do you have any idea for this?
Many thanks in advance!
Mate

 

tex628
Community Champion
Community Champion

[Sales until Last Month2] work on it's own right now? 


Connect on LinkedIn
Anonymous
Not applicable

Yes it works on it's own! Just if I put it into the Calculate function it's shows only the selected month value not the sum of the last 3 month.. Any idea?

tex628
Community Champion
Community Champion

What do you get if you replace the measure with 

SUM(GLEntry[Amount])

Connect on LinkedIn

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors