Forum Discussion
Return Text Value Based on Client ID and Last Date
- 5 years ago
samdep , use this measure for ItemPurchased, if needed take max of date
Measure =
VAR __id = MAX ('Table'[ClientID] )
VAR __date = CALCULATE ( MAX('Table'[PurchaseDate] ), ALLSELECTED ('Table' ), 'Table'[ClientID] = __id )
CALCULATE ( max ('Table'[ItemPurchased] ), VALUES ('Table'[ClientID] ),'Table'[ClientID] = __id,'Table'[PurchaseDate] = __date )
Hi,
This formula is exactly what I need however it keeps telling me the syntax for CALCULATE is incorrect.
Any ideas how to overcome this?
- samdep4 years ago
Advocate II
Can you share your code, plus some sample data?
- bbwong4 years ago
Helper I
Hi samdep,
My sample data is:
Client ID Purchase Date ProductName ID 4001 21/07/2022 Pdt ID-199 4001 20/07/2022 Pdt ID-200 4001 19/07/2022 Pdt ID -202 4001 18/07/2022 Pdt ID -201 Output:
Client ID Purchase Date ProductName ID 4001 21/07/2022 Pdt ID-199 Code is:
Measure =
VAR __id = MAX ('Table'[ClientID] )
VAR __date = CALCULATE ( MAX('Table'[PurchaseDate] ), ALLSELECTED ('Table' ), 'Table'[ClientID] = __id )
CALCULATE ( max ('Table'['ProductName ID] ), VALUES ('Table'[ClientID] ),'Table'[ClientID] = __id,'Table'[PurchaseDate] = __date )Appreciate your assistance.
- HomerSimpson1233 years agoFrequent Visitor
Hi,
I also have an similar issue but keep getting an error with the calculate. Did you manage to find a solution for the calculate error? I don't think anyone replied back for a full response to the calculate error in the below measure....
Did you finally get a solution? Could you share if possible?
Thanks in advanced.
Measure =
VAR __id = MAX ('Table'[ClientID] )
VAR __date = CALCULATE ( MAX('Table'[PurchaseDate] ), ALLSELECTED ('Table' ), 'Table'[ClientID] = __id )
CALCULATE ( max ('Table'[ItemPurchased] ), VALUES ('Table'[ClientID] ),'Table'[ClientID] = __id,'Table'[PurchaseDate] = __date )- bbwong3 years ago
Helper I
Hi,
You could try this:
Measure =
VAR __id = MAX('Table'[ClientID])
VAR __date =
CALCULATE(
MAX('Table'[PurchaseDate]),
ALLSELECTED('Table'),
'Table'[ClientID] = __id
)
RETURN
CALCULATE(
MAX('Table'[ItemPurchased]),
'Table'[ClientID] = __id,
'Table'[PurchaseDate] = __date
)