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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Zimanko
New Member

Filtering groups based on two columns with a twist

Hello everyone!

I need to filter the following table:

Zimanko_0-1700947071497.png
If in_qty_oh > 0 and ord_pol = "LFL" but if the conditions are met I need to show all rows from the In_part group.
So the results should look like this:

Zimanko_1-1700947167162.png

2 REPLIES 2
ThxAlot
Super User
Super User

Simple enough by DAX measure,

ThxAlot_0-1700964312294.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



ronrsnfld
Super User
Super User

Explanation in code comments:

We group by part, then test each grouped table.

 

let

//change next line to reflect actual data source
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{
        {"ln_part", type text}, {"in_site", Int64.Type}, {"in_qty_oh", Int64.Type}, {"ord_pol", type text}}),

//Group by Part with no aggregation
    #"Grouped Rows" = Table.Group(#"Changed Type", {"ln_part"}, {
        {"all", each _, 
        type table [ln_part=nullable text, in_site=nullable number, in_qty_oh=nullable number, ord_pol=nullable text]}}),

//Check if filtered, grouped table has any row that meets criteria
//   Return true/false for filtering
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", 
        each Table.RowCount(Table.SelectRows([all], (t)=>
                t[in_qty_oh]>0 and t[ord_pol]="LFL")) > 0, type logical),

//Remove the grouped rows where the filter of the grouped did not return any rows
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] = true)),

//remove filter column and re-expand the "groups"
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Custom"}),
    #"Expanded all" = Table.ExpandTableColumn(#"Removed Columns", "all", {"ln_part", "in_site", "in_qty_oh", "ord_pol"}, {"ln_part.1", "in_site", "in_qty_oh", "ord_pol"})
in
    #"Expanded all"

 

ronrsnfld_0-1700953264170.png

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors