Forum Discussion
Dax Table Summarize using Lookup
Hi,
I want to summarize a table keeping the corresponding values/Dates from a neighbouring column after an expression.
As the example shows I'm hoping to summarize the animals, calculate the earlisest (min) Analysis Date, and keep it's neighbouring FInalise Date.
Appreciate any help.
Thanks
IDEAL_Backtest_Details = ADDCOLUMNS( SUMMARIZE(Backtest_Details, Backtest_Details[Animals], "Analysis Date", min(Backtest_Details[Analysis Date]) ) , "Final Date", LOOKUPVALUE(Backtest_Details[Final Date], Backtest_Details[Animals], [Animals], Backtest_Details[Analysis Date], [Analysis Date]) )something like this?
IP: Backtest_Details
OP:
Hi NMOORE
if you're looking for a calculated table solution, you may try
NewTable =
GENERATE (
VALUES ( 'Table'[Animals] ),
CALCULATETABLE (
TOPN (
1,
SELECTCOLUMNS (
'Table',
"Analysis Date", 'Table'[Analysis Date],
"Finalise Date", 'Table'[Finalise Date]
),
'Table'[Analysis Date], ASC
)
)
)Thanks alot for this, I was playing around with it for a while trying to do exactly this but just couldnt get there. Much appreciated.
7 Replies
- sevenhillsSuper User
IDEAL_Backtest_Details = ADDCOLUMNS( SUMMARIZE(Backtest_Details, Backtest_Details[Animals], "Analysis Date", min(Backtest_Details[Analysis Date]) ) , "Final Date", LOOKUPVALUE(Backtest_Details[Final Date], Backtest_Details[Animals], [Animals], Backtest_Details[Analysis Date], [Analysis Date]) )something like this?
IP: Backtest_Details
OP:
- NMOOREHelper II
Thanks alot for this, I was playing around with it for a while trying to do exactly this but just couldnt get there. Much appreciated.
- sevenhillsSuper User
Please mark my reply as solution if you like it and also helps for the folks in future those who refer this thread.
- tamerj1Community Champion
Hi NMOORE
if you're looking for a calculated table solution, you may try
NewTable =
GENERATE (
VALUES ( 'Table'[Animals] ),
CALCULATETABLE (
TOPN (
1,
SELECTCOLUMNS (
'Table',
"Analysis Date", 'Table'[Analysis Date],
"Finalise Date", 'Table'[Finalise Date]
),
'Table'[Analysis Date], ASC
)
)
)- NMOOREHelper II
Hi, Thanks so much for your reply, I was trying to understand summarize and add columns better as I was half-way there but will look at understanding what you did here next week. Thanks again
- lbendlinSuper User
No DAX needs to be harmed for this, You can do this entirely in Power Query. Sort by Analysis Date ascending and then deduplicate by Animals.
- NMOOREHelper II
Yes, easy in Power Query, already accomplished. The question was for DAX