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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply

DAX formula to LOOKUP result based on Date AND ignoring blanks?

GooseHelpful199_1-1681936603889.png

 

I have a query that looks like Query 1, and I want to create a Query 2 where I duplicate Query 1, remove duplicates on the "Item" column, and then pull the latest "Case Size" result.

The issues with this are that LOOKUPVALUE wont work with multiple results, I need to only use the latest result, and that I need to ignore results that are blank (without removing the data from Query 1). I believe that the solution requires utilizing FILTER, MAX, and FIRSTNONBLANK functions, but I am having trouble with creating a solution that works. Below is the closest thing I can think of that is similar to other formulas I've got to work, but I cant seem to get this one to work as intended. Any ideas on how to get this to work, or for a different solution altogether?

Latest Case Size =
VAR Latest_Time_=
    CALCULATE(
        MAX ( 'Query 1'[Date] ),
        FILTER ( ALL ( 'Query 1' ), 'Query 1'[Item] = 'Query 2'[Item])
    )
RETURN
CALCULATE (
    FIRSTNONBLANK ('Query 1'[Case Size], 1 ),
    FILTER ( ALL('Query 1'), 'Query 1'[Order Date] = Latest_Time_ )
)
1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@GooseHelpful199 

pls try this

Measure = 
VAR _last=maxx(FILTER('Table','Table'[Item]=max('Table'[Item])&&not(ISBLANK('Table'[Case Size]))),'Table'[Date])
return maxx(FILTER('Table','Table'[Item]=max('Table'[Item])&&'Table'[Date]=_last),'Table'[Case Size])

pls see the attachment below





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

Proud to be a Super User!




View solution in original post

3 REPLIES 3
ryan_mayu
Super User
Super User

@GooseHelpful199 

pls try this

Measure = 
VAR _last=maxx(FILTER('Table','Table'[Item]=max('Table'[Item])&&not(ISBLANK('Table'[Case Size]))),'Table'[Date])
return maxx(FILTER('Table','Table'[Item]=max('Table'[Item])&&'Table'[Date]=_last),'Table'[Case Size])

pls see the attachment below





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

Proud to be a Super User!




This worked perfectly, thanks!

you are welcome





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

Proud to be a Super User!




Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 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.