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
sw123
Helper III
Helper III

Sales for the last 5 months

Hi,

Can you tell me what is wrong with this measure? I want the table to show sales for the last 5 months from today:

 

Sales Period = CALCULATE(
SUM(F_Invoice[Sales]);
DATESINPERIOD(F_Invoice[Invoicedate];
LASTDATE(F_Invoice[Invoicedate]);
-5;MONTH))
1 ACCEPTED SOLUTION
harshnathani
Community Champion
Community Champion

Hi @sw123 ,

 

You can try

 

CALCULATE(SUM(F_Invoice[Sales]),DATESBETWEEN(F_Invoice[Invoicedate],EDATE(EOMONTH(TODAY(),-1)+1,-5),EOMONTH(TODAY(),-1)+1))

 

 

or 

 

Try using MAX instead of LASTDATE

 

Sales Period = CALCULATE(
SUM(F_Invoice[Sales]);
DATESINPERIOD(F_Invoice[Invoicedate];
MAX(F_Invoice[Invoicedate]);
-5;MONTH))
 
 
You can also see the below blog
 
Regards,
Harsh Nathani

View solution in original post

5 REPLIES 5
harshnathani
Community Champion
Community Champion

Hi @sw123 ,

 

You can try

 

CALCULATE(SUM(F_Invoice[Sales]),DATESBETWEEN(F_Invoice[Invoicedate],EDATE(EOMONTH(TODAY(),-1)+1,-5),EOMONTH(TODAY(),-1)+1))

 

 

or 

 

Try using MAX instead of LASTDATE

 

Sales Period = CALCULATE(
SUM(F_Invoice[Sales]);
DATESINPERIOD(F_Invoice[Invoicedate];
MAX(F_Invoice[Invoicedate]);
-5;MONTH))
 
 
You can also see the below blog
 
Regards,
Harsh Nathani

Thanx, still not working, though 😞

Now I read you blog more carefully and used the last updated simpler formula and it worked! Great thanx!

stevedep
Memorable Member
Memorable Member

You can try:

Sales Period = CALCULATE(
SUM(F_Invoice[Sales]);all(F_Invoice[Invoicedate]);
DATESINPERIOD(F_Invoice[Invoicedate];
LASTDATE(F_Invoice[Invoicedate]);
-5;MONTH))

Thanx, but it is still not working as it should 😞

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.