Forum Discussion
MTD and YTD calculation
- 5 years ago
Billed Hours Last Year MTD = var lastNonEmtpyDate = LASTNONBLANK(ALL(Calendar[Date]),[Billed Hours]) return IF(HASONEVALUE('Calendar'[Date]), CALCULATE ( [Billed Hours], SAMEPERIODLASTYEAR(DATESMTD( (Calendar[Date]))), FILTER( ALL(Calendar[Date]), Calendar[Date]<=MAX( 'Billed Hours MTD dax'[Date])) ), CALCULATE([Billed Hours], DATEADD( FILTER(DATESMTD((Calendar[Date])),Calendar[Date]<= lastNonEmtpyDate ), -1, YEAR )))
Hi FarhanAhmed,
I am facing some issue with the the above formula as in screenshot below. Also i have attached my Pbix file in the link below for reference.
It would be great if you could review the file and let me know where i am missing
Sorry can't open pbix right now
But There seems to be 2 ALL in LASTNONBLANK with Calendar date which is causing this error
Also make sure that brackets are closed properly.
- Powereports5 years ago
Helper I
Hi FarhanAhmed,
Can you email your mail id to send the Pbix?
- Powereports5 years ago
Helper I
Hi FarhanAhmed,
I guess this time i tried rectifying and closing the brackets but still unable to get there. Any leads would be appreciated.
- FarhanAhmed5 years ago
Community Champion
Seems like first calculate missing 1 close bracket and 2nd one has 1 extra bracket
- Powereports5 years ago
Helper I
Thanks for the quick correction Farhan. The Dax works but somehow i get no value populated in the visual as below 😑.. Any insights?