Hi, I have a table that looks like this:
Order ID | Link ID | Order Date | Order Status |
101 | 5016 | 6/17/2019 | Y |
102 | 5016 | 4/20/2022 | N |
103 | 5016 | 7/23/2018 | Y |
111 | 5014 | 5/5/2020 | N |
112 | 5014 | 1/4/2021 | Y |
Each Link ID can have multiple Order ID's. What I'm trying to do is look up Orders based on the Link ID, and return the Max of Order Date, and that Max Order Date's corresponding Order Status. Like Below (Link Date and Link Status):
Order ID | Link ID | Order Date | Order Status | Link Date | Link Status |
101 | 5016 | 6/17/2019 | Y | 4/20/2022 | N |
102 | 5016 | 4/20/2022 | N | 4/20/2022 | N |
103 | 5016 | 7/23/2018 | Y | 4/20/2022 | N |
111 | 5014 | 5/5/2020 | N | 1/4/2021 | Y |
112 | 5014 | 1/4/2021 | Y | 1/4/2021 | Y |
I was able to work out the Link Date DAX formula, but I'm unable to fetch it's corresponding Link Status.
Link Date:
CALCULATE(
MAX(Table[Order Date]),
FILTER((Table), Table[Link ID] = earlier(Table[Link ID]))
)
How do I get the corresponding Order Status for the Link Date?
Any help is appreciated.
Edit: I goofed up the formatting, but here's a clearer picture
Solved! Go to Solution.
@RustyNails Try:
Link Status =
VAR __LinkID = MAX(Table[Link ID])
VAR __LinkDate =
CALCULATE(
MAX(Table[Order Date]),
FILTER((Table), Table[Link ID] = __LinkID )
)
RETURN
MAXX(FILTER(ALL(Table),Table[Link ID] = __LinkID && Table[Order Date] = __LinkDate),[Link Status])
@RustyNails Try:
Link Status =
VAR __LinkID = MAX(Table[Link ID])
VAR __LinkDate =
CALCULATE(
MAX(Table[Order Date]),
FILTER((Table), Table[Link ID] = __LinkID )
)
RETURN
MAXX(FILTER(ALL(Table),Table[Link ID] = __LinkID && Table[Order Date] = __LinkDate),[Link Status])
You're a genius. Thank you for the quick response!!!
User | Count |
---|---|
117 | |
62 | |
60 | |
47 | |
40 |
User | Count |
---|---|
111 | |
63 | |
62 | |
51 | |
48 |