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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Chimsie
Helper III
Helper III

How LastNonBlank with multiple asset IDs

Hi everyone 

 

I have a table which collected data from a realtime sources, sometimes it happens that the collections fails for some reason on some assets, now I am trying to populate these missing values with the most recent value (LASTNONBLANK) at that point in time.

 

For example: 

 

Table1 

     Date          AssetID    Value  Calculated column 

10/09/2020    11202       3.42              3.42 

10/09/2020    14210       6.50              6.50 

10/09/2020    19500       2.21              2.21 

10/09/2020    21200       7.25              7.25 

11/09/2020    11202       3.66              3.66 

11/09/2020    14210       null               6.50 

11/09/2020    19500       null               2.21 

11/09/2020    21200       7.95              7.95 

12/09/2020    11202       null               3.66 

12/09/2020    14210       7.12              7.12 

12/09/2020    19500       null               2.21 

12/09/2020    21200       null               7.25 

13/09/2020    14210       6.91               etc. 

13/09/2020    19500       2.01 

13/09/2020    21200       null 

13/09/2020    11202       3.10 

 

An Assets ID tries to poll data every day, if this fails, null is written in the column value for this asset. 

With the help of the this forum I was able the fill the blanks for a unique Asset ID with below DAX formular

  

=LOOKUPVALUE(Table1[Value],Table1[AssetID],Table1[AssetID],Table1[Date], 

CALCULATE(LASTNONBLANK(Table1 [Date], 1), 

FILTER(Table1,Table1[Value]>0 &&EARLIER(Table1 [Date])>= Table1 [Date]))) 

 

But this DAX formular does not work with multiple asset IDs 

 

Can some one help? 

1 ACCEPTED SOLUTION

Hi @Chimsie,

 

Please try the following calculated column

 

calc value = 
    var assetid = [AssetID]
    var curDate = [Date]
    var priorMaxDate = CALCULATE(MAX('Table1'[Date]), FILTER('Table1', 'Table1'[AssetID] = assetid && [Date] < curDate && 'Table1'[Value] <> BLANK()))
return 
   if([Value] = blank(), CALCULATE(max('Table1'[Value]), FILTER('Table1', [AssetID] = assetid && [Date] = priorMaxDate)), 'Table1'[Value])

 

Hope this Helps,
Richard
Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@Chimsie , Try a new column like

if(isblank(Table[Value]),
CALCULATE(LASTNONBLANKvalue(Table1 [Date], max(Table[Value])), FILTER(Table1, Table1[AssetID]= EARLIER(Table1[AssetID]) && Table1 [Date] < EARLIER(Table1 [Date])))
,Table[Value] )

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

@amitchandak 

This returns A circular dependency was detected: Table[Result]

 

Snap.PNG

 

Any idea?

Hi @Chimsie,

 

Please try the following calculated column

 

calc value = 
    var assetid = [AssetID]
    var curDate = [Date]
    var priorMaxDate = CALCULATE(MAX('Table1'[Date]), FILTER('Table1', 'Table1'[AssetID] = assetid && [Date] < curDate && 'Table1'[Value] <> BLANK()))
return 
   if([Value] = blank(), CALCULATE(max('Table1'[Value]), FILTER('Table1', [AssetID] = assetid && [Date] = priorMaxDate)), 'Table1'[Value])

 

Hope this Helps,
Richard
Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


@richbenmintz 

An additional question, is it possible to expand the formula with the following,

When it fails to collect data from a source (assetID) for 3 consecutive days, the calculated column will change to zero for that assetID. this does not have to be retroactive.

 

Thank you, this works perfect:-)

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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