Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Amardeep100115
Post Prodigy
Post Prodigy

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

 

 

Sample data

AB
1 ACCEPTED SOLUTION

@v-diye-msft 

 

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")),

AB

View solution in original post

6 REPLIES 6
v-diye-msft
Community Support
Community Support

Hi @Amardeep100115 

 

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!

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

@v-diye-msft 

 

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")),

AB
Greg_Deckler
Super User
Super User

I don't understand what you want for output. What would your expected output from that sample data be?

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

suppose 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
AB

@Amardeep100115 , 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 )

Greg_Deckler
Super User
Super User

Maybe https://community.powerbi.com/t5/Quick-Measures-Gallery/Lookup-Min-Max/m-p/985814#M434

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.