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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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