Forum Discussion
DAX help - Get latest value for each ID
- 7 years ago
Hi,
This one works
=if(HASONEFILTER(Table1[Name]),LOOKUPVALUE(Table1[Value],Table1[Date],[Latest value],Table1[Name],VALUES(Table1[Name])),BLANK())
Hope this helps.
I do not understand your question at all. May be someone else can help you.
Okay, sorry for taking your time but let me try one more time please. I have a dataset which looks like below and would like to find the last qty of each product based on id:
| id | Product | qty |
| 10001 | Lenovo | 1 |
| 10002 | VIVO | 4 |
| 10003 | Huawei | 5 |
| 10004 | Lenovo | 8 |
| 10005 | VIVO | 9 |
and i would like to see out put like this:
| id | Product | qty |
| 10003 | Huawei | 5 |
| 10004 | Lenovo | 8 |
| 10005 | VIVO | 9 |
i have tried function like this below but the result is in matrix table is empty cells
Latest value = CALCULATE(LASTNONBLANK(Table[qty],""),FILTER(Table,MAX(Table[id])))
and then:
=if(HASONEFILTER(Table[Product]),LOOKUPVALUE(Table[qty],Table[id],[Latest value],Table[Product],VALUES(Table[Product])),BLANK())
i would really appreciate if you could help me with this issue. Thank you!
- Ashish_Mathur4 years ago
Super User
Hi,
Try these measures
Max ID = MAX(Data[id])Qty at Max ID = CALCULATE(SUM(Data[qty]),FILTER(VALUES(Data[id]),Data[id]=CALCULATE([Max ID],all(Data[id]))))Hope this helps.