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

View all the Fabric Data Days sessions on demand. View schedule

Reply
carlobonan
Helper II
Helper II

Strange behavior measures last month for only two values

Hi everyone I have a problem with this formula:

 

01_C_LAST_MONTHS_A+B = var current_month= MONTH(TODAY())
return CALCULATE(SUM('01_DB_GLOBALE'[SaldoC]), FILTER('01_DB_GLOBALE', '01_DB_GLOBALE'[TIPO_PTF]="a" || '01_DB_GLOBALE'[TIPO_PTF]="b"), MONTH('01_DB_GLOBALE'[DATA_CORRETTA])=current_month -2)

 

 

image.png

 

ONLY for two items it also calculates the dates prior to the previous month.

I would like to calculate the max date of the previous month (sometimes it will be 29, other 30 ..)

tips?

 

thanks

 

C.

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@carlobonan , not very clear. The image is missing. Or did not load for me

 

Use time intelligence with help from date table

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))

 

Month behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Month))

2 Month behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-2,Month))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
carlobonan
Helper II
Helper II

@amitchandak  sorry, here is the reloaded image. as you can see, for some items it also calculates the values ​​at dates other than the end of month


unnamed.png

amitchandak
Super User
Super User

@carlobonan , not very clear. The image is missing. Or did not load for me

 

Use time intelligence with help from date table

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))

 

Month behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Month))

2 Month behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-2,Month))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@Amit thanks 

 

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