Forum Discussion
Help Needed on LASTNOBLANK dax function
- 10 months ago
Hi Everyone,
https://github.com/kumarabhinay/Power_BI/blob/main/FirstLastNoBlank.pbix
A simple calculate function over the expression fixed the issue.I tried so hard using AI but failed. This simple tutorial reminded the concept of filter context required for these set of functions to work
Thank you very much!
Hey arkenstones ,
The reason you are getting Jan 4th instead of Jan 3rd as the last sale date is due to how LASTNONBLANK works in combination with SUM(Sales[SalesAmount]). On Jan 3rd, although there is a record for Product A, the quantity is zero, which results in a SalesAmount of zero. In DAX, LASTNONBLANK treats a zero result from the expression (in your case, SUM(Sales[SalesAmount])) as blank for the purpose of this function. So, LASTNONBLANK skips Jan 3rd and returns Jan 4th, which has actual non-zero sales amounts for both Product A and B.
Last Sale Date (New) =
CALCULATE(
MAX(Sales[Date]),
FILTER(
Sales,
NOT(ISBLANK(Sales[SalesAmount]))
)
)
Please check the attached pbix file.
Best Regards,
Nasif Azam
- arkenstones10 months agoNew Member
Hi Nasif_Azam
Thank you for your reply. Your solution is definately correct and does the job but Im exploring whether I can get the result for product B using LastNoBlank() Dax function like I got correct result for product A. Quantity column in the table has no use as I consider the salesamount as the product or price and quanity (which is confusing, sorry about that).
Thank you very much!