Forum Discussion
Getting a previous value using 2 matching columns
- Anonymous4 years ago
Hi SClarke501 ,
You can create a calculated column as below, please find the details in the attachment.
Left = VAR _predate = CALCULATE ( MAX ( 'Table'[Entry Date] ), FILTER ( 'Table', 'Table'[ID] = EARLIER ( 'Table'[ID] ) && 'Table'[Entry Date] < EARLIER ( 'Table'[Entry Date] ) ) ) RETURN CALCULATE ( MAX ( 'Table'[Entered] ), FILTER ( 'Table', 'Table'[ID] = EARLIER ( 'Table'[ID] ) && 'Table'[Entry Date] = _predate ) )Best Regards
Hey SClarke501 ,
I have created two extra columns to use the LOOKUPVALUE function:
Based on these keys, we can use the LOOKUPVALUE function:
I hope this helps you out!
- SClarke5014 years agoFrequent Visitor
Hi Anonymous
Great idea on the extra columns, hadn't thought of that.
However I'm getting an error on the LOOKUPVALUE: A table of multiple values was supplied where a single value was expected.
Is this because the "Entered" column has duplicates in the real data?
- Anonymous4 years agoNot applicable
Hi SClarke501,
No, the entered column should not be the problem. The lookup values has to be unique. That is why I created these keys. I assumed that these are unique. So if an ID enters or exits an country twice on the same day, the key is not unique any more. Can you search the Enrty-date and Exit-date columns we created for duplicates?- SClarke5014 years agoFrequent Visitor
Yes unfortunately I spotted a duplicate. Very surprising since my real data has datetime instead of just date. But there are two entries that apparently happen on the exact same date at the exact same time!
Is there any way around this? I thought to maybe append some more data to the new columns to make them unique but there isn't anything to use.