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
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
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.