Forum Discussion
Find row with latest date and keep one
- 5 years ago
Continuing on the code you had above:
Row_Group_by_ForestDNSName = Table.Group(Row_Filter, {"ForestDNSName"}, {{"Count", each _, type table}}), Extract_Latest_Data = (TT as table) => Table.SelectRows(TT, each [Scan Date] = List.Max(TT[Scan Date])), Custom_Column_LatestData = Table.AddColumn(Row_Group_by_ForestDNSName, "LatestData", each Extract_Latest_Data([Count])), Column_Remove_Except_LatestData = Table.RemoveColumns(Custom_Column_LatestData,{"ForestDNSName", "Count"}), #"Added Custom" = Table.AddColumn(Column_Remove_Except_LatestData, "Custom", each Table.FirstN([LatestData],1)), #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Scan Date", "ForestDNSName"}, {"Scan Date", "ForestDNSName"}), #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"LatestData"})Please mark the question solved when done and consider giving kudos if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
Hi PowerBeeEye
Try Table.FirstN to keep the first row only:
Table.FirstN(TableName , 1)
Please mark the question solved when done and consider giving kudos if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
AlB I'm very much a beginner when **bleep** comes to this, how can I add
Table.FirstN(TableName , 1)
to either of the following lines?
Extract_Latest_Data = (TT as table) =>
Table.SelectRows(TT, each [Scan Date] = List.Max(TT[Scan Date])),
OR
Custom_Column_LatestData = Table.AddColumn(Row_Group_by_ForestDNSName, "LatestData", each Extract_Latest_Data([Count])),
Thanks!
- AlB5 years ago
Community Champion
Continuing on the code you had above:
Row_Group_by_ForestDNSName = Table.Group(Row_Filter, {"ForestDNSName"}, {{"Count", each _, type table}}), Extract_Latest_Data = (TT as table) => Table.SelectRows(TT, each [Scan Date] = List.Max(TT[Scan Date])), Custom_Column_LatestData = Table.AddColumn(Row_Group_by_ForestDNSName, "LatestData", each Extract_Latest_Data([Count])), Column_Remove_Except_LatestData = Table.RemoveColumns(Custom_Column_LatestData,{"ForestDNSName", "Count"}), #"Added Custom" = Table.AddColumn(Column_Remove_Except_LatestData, "Custom", each Table.FirstN([LatestData],1)), #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Scan Date", "ForestDNSName"}, {"Scan Date", "ForestDNSName"}), #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"LatestData"})Please mark the question solved when done and consider giving kudos if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers