Forum Discussion
arkenstones
10 months agoNew Member
Help Needed on LASTNOBLANK dax function
Hi Friends, It may sound silly but im facing a problem in calculating lastnoblank sales date - https://github.com/kumarabhinay/Power_BI/blob/main/LastNoBlank.pbix I should get Jan 3rd as the las...
- 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!
Ahmedx
10 months agoSuper User
In your data the last sales date for A is Jan 4th
Ahmedx
10 months agoSuper User
If you want to get the previous figures for 0 sales, you can do it like this
or
or
am =
VAR _Am = SUM(Sales[SalesAmount])
RETURN
IF( ISBLANK(_Am), MAXX(
TOPN(1, FILTER(ALL(Sales), 'Sales'[Date]<MAX('Sales'[Date])),[Date],0),[SalesAmount])
,_Am
)- arkenstones10 months agoNew Member
Hi Ahmedx,
Thank you for your reply with the suggestions, but i was interesting in getting the lastsaledate using LastNoBlank() dax function. However, i definately learnt something from your solution.
Thank you very much!- Ahmedx10 months agoSuper User
Ok, pls try this
SalesDate= CALCULATE(LASTNONBLANK('Sales'[Date],CALCULATE(SUM(Sales[SalesAmount]))),'Sales'[Date]<MAX('Sales'[Date])) ---------------- SalesNoBlank= CALCULATE(LASTNONBLANKVALUE('Sales'[Date],CALCULATE(SUM(Sales[SalesAmount]))),'Sales'[Date]<MAX('Sales'[Date]))