Forum Discussion
MitaSaxena
4 years agoFrequent Visitor
Help with filter or if statement
Excel file for powerbi filter help Hi, please can someone help. I have a sequence of communication events associated with a job and the date they are logged. I want to be able to only see the lat...
AlexisOlson
4 years agoSuper User
You can select the even types in question (Emailed query, General Helpdesk Job Not, Response by contractor) and the group by Job Seq taking the top row ordered by datetime. Then expand this row and filter only the Emailed Query rows.
let
Source = <Your Excel Table>,
#"Filtered Rows" = Table.SelectRows(Source, each ([EVENT NAME] = "Emailed Query" or [EVENT NAME] = "General Helpdesk Job Note" or [EVENT NAME] = "Response by contractor")),
#"Grouped Rows" = Table.Group(#"Filtered Rows", {"JOB ID"}, {{"LastEvent", each Table.Max(_, "DATE & TIME"), type record}}),
#"Expanded LastEvent" = Table.ExpandRecordColumn(#"Grouped Rows", "LastEvent", {"EVENT ID", "EVENT NAME", "DATE & TIME", "COMMENT"}, {"EVENT ID", "EVENT NAME", "DATE & TIME", "COMMENT"}),
#"Filtered Rows1" = Table.SelectRows(#"Expanded LastEvent", each ([EVENT NAME] = "Emailed Query")),
#"Reordered Columns" = Table.ReorderColumns(#"Filtered Rows1",{"EVENT ID", "EVENT NAME", "DATE & TIME", "COMMENT", "JOB ID"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Reordered Columns",{{"EVENT ID", Int64.Type}, {"EVENT NAME", type text}, {"DATE & TIME", type datetime}, {"COMMENT", type text}, {"JOB ID", Int64.Type}})
in
#"Changed Type1"
The only tricky bit is the Table.Max part in the Group By step. For more detail on that, see Approach #3 from my post here:
Select Distinct Rows Ordered by Another Column