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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply

Lookup latest date, but dealing with multiple values

Hi - I have the attached data.  The data on left represents the source data (shaded yellow), and the data to the right (shaded all blue) represents the desired result using some form of lookup.

 

I need to basically lookup the corresponding value of the latest date, corresponding to height and weight.  Where there is a blank, I need to use the next available date which has a value and return this value.

 

I also need to show the measure date associated with each value (height and weight) to determine whether the two dates are close enough to consider accurate enough to use.  

 

Tricky one...any ideas?  If possible I want to achieve this result using a calculated column using lookup or a derivative of.

 

Thanks all.  Really appreciate your help as always.

 

Sample Data 

1 ACCEPTED SOLUTION
vanessafvg
Super User
Super User

vanessafvg_0-1737659539165.png

 

Last Valid Weight =
VAR lastdte =
CALCULATE (
MAX ( CustomerWeight[Measure Date] ),
NOT ( ISBLANK ( CustomerWeight[Weight] ) )
)
VAR result =
CALCULATE (
MAX ( CustomerWeight[Weight] ),
CustomerWeight[Measure Date] = lastdte
)
RETURN
IF ( result = 0, "No Height Listed", result )

 





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




View solution in original post

9 REPLIES 9
vanessafvg
Super User
Super User

vanessafvg_0-1737659539165.png

 

Last Valid Weight =
VAR lastdte =
CALCULATE (
MAX ( CustomerWeight[Measure Date] ),
NOT ( ISBLANK ( CustomerWeight[Weight] ) )
)
VAR result =
CALCULATE (
MAX ( CustomerWeight[Weight] ),
CustomerWeight[Measure Date] = lastdte
)
RETURN
IF ( result = 0, "No Height Listed", result )

 





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




v-linhuizh-msft
Community Support
Community Support

Thanks for the replies from vanessafvg.

 

Hi @Creative_tree88 ,

 

You can try to create the following four measures:

Latest Height = CALCULATE(SUM('Table'[Height]),FILTER(ALLEXCEPT('Table','Table'[Customer No]),'Table'[Measure Date]=[Measure Height Date]))
Latest Weight = CALCULATE(SUM('Table'[Weight]),FILTER(ALLEXCEPT('Table','Table'[Customer No]),'Table'[Measure Date]=[Measure Weight Date]))
Measure Height Date = CALCULATE(MAX('Table'[Measure Date]),FILTER(ALLEXCEPT('Table', 'Table'[Customer No]),'Table'[Height]>0))
Measure Weight Date = CALCULATE(MAX('Table'[Measure Date]),FILTER(ALLEXCEPT('Table', 'Table'[Customer No]),'Table'[Weight]>0))

 

Result:

vlinhuizhmsft_0-1737626694728.png

 

 

Best Regards,
Zhu

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.

vanessafvg
Super User
Super User

there might be an easier way to do it i filtered only on these results as the dates gave me some issues on copying and pasting but essentially it gives the correct answer

 

you need to do a dax calculation 

so get the last valid height

 

Last Valid Height =
VAR lastdte =
CALCULATE (
MAX ( CustomerWeight[Measure Date] ),
NOT ( ISBLANK ( CustomerWeight[Height] ) )
)
RETURN
CALCULATE (
MAX ( CustomerWeight[Height] ),
CustomerWeight[Measure Date] = lastdte
)

 

and for the date 

 

Last Valid Height Date =
CALCULATE (
MAX ( CustomerWeight[Measure Date] ),
NOT ( ISBLANK ( CustomerWeight[Height] ) )
)

 

vanessafvg_0-1737576495406.png

 

 

see solution attached 





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




@vanessafvg That looks good.  I'll do some data quality checks tomorrow and, if it's OK with you, get back to you if there are any further issues I find once I've incorporated this into my report.  Many thanks indeed.

@vanessafvg Is there a way of introducing text to each measure, to add to the table in the event of there being no data to return.  For example 'No Height Data' where there is nothing.  Many thanks again.

you could but it would not longer be a numeric piece of data, it would need to be come  a text column, it could be solved  by using an if statement.   are you wanting it to be text?





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




@vanessafvg It could be text, yes.  Would be interested to see the result.

Apologies @vanessafvg here's the updated sample.  You are correct, it needs to be based on customer.

 

Sample Data 

 

vanessafvg
Super User
Super User

do you want the result at a customer level ie per customerr last height and weight as you didn't include in on your result table





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors