Forum Discussion
Filter Table by Max date time value
Hi,
this is a survey data where people have submitted multiple times survey andwant filter survey by most recent not first survey
i tried to get it by grouping Completion date by MAX but no use
Please guide
- Anonymous6 years ago
Yeah,
got the answer for this
please see the below m-code which i used for my query
#"Grouped Rows" = Table.Group(Source, {"Email"}, {{"Max Completion Time", each List.Max([Completion time]), type datetime}, {"All Rows", each _, type table [Source=text, ID=text, Start time=datetime, Completion time=datetime]}}),
#"Expanded All Rows" = Table.ExpandTableColumn(#"Grouped Rows", "All Rows", {"Source", "ID", "Start time", "Completion time", "}),
#"Added Conditional Column" = Table.AddColumn(#"Expanded All Rows", "Keep", each if [Max Completion Time] = [Completion time] then "Keep" else "Remove"),
#"Filtered Rows" = Table.SelectRows(#"Added Conditional Column", each ([Keep] = "Keep")),
6 Replies
- Greg_DecklerCommunity ChampionI don't understand what you want for output. What would your expected output from that sample data be?
- AnonymousNot applicablesuppose if i have submitted survey a hour back and i changed my mind and resubmitted again same survey with another details. here i want to filter most recent survey by datetime. means my second survey should be there not earlier one
- amitchandakSuper User
Anonymous , can not say without looking at data, but something like this
Measure =
VAR __id = MAX ( 'Table'[ID] )
VAR __date = CALCULATE ( MAX( 'Table'[date] ), ALLSELECTED ( 'Table' ), 'Table'[ID] = __id )
RETURN CALCULATE ( Max ( 'Table'[Text] ), VALUES ( 'Table'[ID ), 'Table'[ID] = __id, 'Table'[date] = __date )
- v-diye-msftCommunity Support
Hi Anonymous
If you've fixed the issue on your own please kindly share your solution. if the above posts help, please kindly mark it as a solution to help others find it more quickly.thanks!
- AnonymousNot applicable
Yeah,
got the answer for this
please see the below m-code which i used for my query
#"Grouped Rows" = Table.Group(Source, {"Email"}, {{"Max Completion Time", each List.Max([Completion time]), type datetime}, {"All Rows", each _, type table [Source=text, ID=text, Start time=datetime, Completion time=datetime]}}),
#"Expanded All Rows" = Table.ExpandTableColumn(#"Grouped Rows", "All Rows", {"Source", "ID", "Start time", "Completion time", "}),
#"Added Conditional Column" = Table.AddColumn(#"Expanded All Rows", "Keep", each if [Max Completion Time] = [Completion time] then "Keep" else "Remove"),
#"Filtered Rows" = Table.SelectRows(#"Added Conditional Column", each ([Keep] = "Keep")),