Forum Discussion
Filtering Virtual Table to Display Latest Purchase for Each User Using DAX
- Anonymous1 year ago
Thanks for the reply from lbendlin , please allow me to provide another insight:
Hi, Anonymous
Regarding the issue you raised, my solution is as follows:
1.My sample data is as follows:
2.As I am unsure how you have constructed the CALCULATETABLE(), I will assume that I only need the entries with IDs 1 and 2:
TableA=CALCULATETABLE(SELECTCOLUMNS( 'Table', "User_ID1", 'Table'[User ID], "Date_of_Purchase1", 'Table'[Date of Purchase] ),'Table'[User ID] IN {1,2})3.Here is my calculated table:
Table2 = VAR TableA = CALCULATETABLE ( SELECTCOLUMNS ( 'Table', "User_ID1", 'Table'[User ID], "Date_of_Purchase1", 'Table'[Date of Purchase] ), 'Table'[User ID] IN { 1, 2 } ) VAR LatestPurchases = SUMMARIZE ( TableA, [User_ID1], "Latest Purchase Date", MAX ( 'Table'[Date of Purchase] ) ) RETURN LatestPurchases4.Here's my final result, which I hope meets your requirements.
Can you share sample data and sample output in tabular format if I am misunderstanding? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.
Please find the attached pbix relevant to the case.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks for the reply from lbendlin , please allow me to provide another insight:
Hi, Anonymous
Regarding the issue you raised, my solution is as follows:
1.My sample data is as follows:
2.As I am unsure how you have constructed the CALCULATETABLE(), I will assume that I only need the entries with IDs 1 and 2:
TableA=CALCULATETABLE(SELECTCOLUMNS(
'Table',
"User_ID1", 'Table'[User ID],
"Date_of_Purchase1", 'Table'[Date of Purchase]
),'Table'[User ID] IN {1,2})
3.Here is my calculated table:
Table2 =
VAR TableA =
CALCULATETABLE (
SELECTCOLUMNS (
'Table',
"User_ID1", 'Table'[User ID],
"Date_of_Purchase1", 'Table'[Date of Purchase]
),
'Table'[User ID] IN { 1, 2 }
)
VAR LatestPurchases =
SUMMARIZE (
TableA,
[User_ID1],
"Latest Purchase Date", MAX ( 'Table'[Date of Purchase] )
)
RETURN
LatestPurchases
4.Here's my final result, which I hope meets your requirements.
Can you share sample data and sample output in tabular format if I am misunderstanding? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.
Please find the attached pbix relevant to the case.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous1 year agoNot applicable
This works well !