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

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

@Amit thanks 

 

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.