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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Vialle_Diego
Frequent Visitor

Filter column based on two rules

I need to filter the "Case" column based on the most recent date in the "Opened on" column, and keeping the information in the "Assignment Group" column. The "Case" column has duplicate values.

 

Vialle_Diego_2-1668704918968.png

@tamerj1 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Vialle_Diego ,

Please refer to this step.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Vc9LDoAgDEXRvXRMUiigY1A+UXdg2P82xMEzddaXM7jpfZOz1pEhx47FiswzJRrmA2EB5KzBswdsG+BdgQNg3zVEjoBSAP7fqFXDwgugNUD4N3oHxLlWXgHXpUE1jkOD+uM8aYwH", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Case = _t, #"Opened on" = _t, #"Assignment Group" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Case", Int64.Type}, {"Opened on", type date}, {"Assignment Group", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Case"}, {{"Data", each _, type table [Case=nullable number, Opened on=nullable date, Assignment Group=nullable text]}, {"Max Date", each List.Max([Opened on]), type nullable date}}),
    #"Expanded Data" = Table.ExpandTableColumn(#"Grouped Rows", "Data", {"Opened on", "Assignment Group"}, {"Opened on", "Assignment Group"}),
    #"Added Conditional Column" = Table.AddColumn(#"Expanded Data", "Custom", each if [Opened on] = [Max Date] then 1 else null),
    #"Filtered Rows" = Table.SelectRows(#"Added Conditional Column", each ([Custom] = 1)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Max Date", "Custom"})
in
    #"Removed Columns"

Original table:

vcgaomsft_1-1668757586868.png

Result:

vcgaomsft_2-1668757618108.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Vialle_Diego ,

Please refer to this step.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Vc9LDoAgDEXRvXRMUiigY1A+UXdg2P82xMEzddaXM7jpfZOz1pEhx47FiswzJRrmA2EB5KzBswdsG+BdgQNg3zVEjoBSAP7fqFXDwgugNUD4N3oHxLlWXgHXpUE1jkOD+uM8aYwH", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Case = _t, #"Opened on" = _t, #"Assignment Group" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Case", Int64.Type}, {"Opened on", type date}, {"Assignment Group", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Case"}, {{"Data", each _, type table [Case=nullable number, Opened on=nullable date, Assignment Group=nullable text]}, {"Max Date", each List.Max([Opened on]), type nullable date}}),
    #"Expanded Data" = Table.ExpandTableColumn(#"Grouped Rows", "Data", {"Opened on", "Assignment Group"}, {"Opened on", "Assignment Group"}),
    #"Added Conditional Column" = Table.AddColumn(#"Expanded Data", "Custom", each if [Opened on] = [Max Date] then 1 else null),
    #"Filtered Rows" = Table.SelectRows(#"Added Conditional Column", each ([Custom] = 1)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Max Date", "Custom"})
in
    #"Removed Columns"

Original table:

vcgaomsft_1-1668757586868.png

Result:

vcgaomsft_2-1668757618108.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.