Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.
Hi all,
is there a way to filter a query on a column, based on the value of another column in PowerQuery?
In my case, I would like to remove a series if it contains any Nan.
Here's an example of the input:
and the desired result:
I have tried with workaround, like filtering a custom column that sums up all the elements according to their value in column 1 (like a sumif in excel), but the dataset is too heavy, and this results to be very very slow...
#"Aggiunta colonna personalizzata2" = Table.AddColumn(#"Rimosse colonne", "Custom Column", each let _item = [Column 1] in
List.Sum(
Table.SelectRows(#"Rimosse colonne", each [Column 1] = _item)[Column 2])),
#"Filtrate righe" = Table.SelectRows(#"Aggiunta colonna personalizzata2", each (not Number.IsNaN([Custom Column])))
Is there a simpler way?
thanks!
Solved! Go to Solution.
@Anonymous you can try this, use group by and then call a function to flag
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTKxVIrVgTCNzOFMMCMJyDA1hTPNzOFMCwgzGaYShWEGMTEFZLgJnAk1HMQ0U4qNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Column1"}, {{"ALL", each _, type table [Column1=nullable text, Column2=nullable number]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each fnFlag([ALL])),
#"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Column2", "Exclude"}, {"Column2", "Exclude"}),
#"Filtered Rows" = Table.SelectRows(#"Expanded Custom", each ([Exclude] = "No")),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"ALL", "Exclude"})
in
#"Removed Columns"
code for the fnFlag function:
(tbl as table) =>
let
Source = tbl,
FilterNull = Table.SelectRows(Source, each [Column2] = null),
RowsCount = Table.RowCount(FilterNull),
AddFlag = Table.AddColumn(Source, "Exclude", each if RowsCount >= 1 then "Yes" else "No")
in
AddFlag
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@Anonymous glad it worked out. Yes, I was not sure about the actual data so just used Null.
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@Anonymous did the provided solution work?
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
yes!
Thanks a lot
@Anonymous you can try this, use group by and then call a function to flag
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTKxVIrVgTCNzOFMMCMJyDA1hTPNzOFMCwgzGaYShWEGMTEFZLgJnAk1HMQ0U4qNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Column1"}, {{"ALL", each _, type table [Column1=nullable text, Column2=nullable number]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each fnFlag([ALL])),
#"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Column2", "Exclude"}, {"Column2", "Exclude"}),
#"Filtered Rows" = Table.SelectRows(#"Expanded Custom", each ([Exclude] = "No")),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"ALL", "Exclude"})
in
#"Removed Columns"
code for the fnFlag function:
(tbl as table) =>
let
Source = tbl,
FilterNull = Table.SelectRows(Source, each [Column2] = null),
RowsCount = Table.RowCount(FilterNull),
AddFlag = Table.AddColumn(Source, "Exclude", each if RowsCount >= 1 then "Yes" else "No")
in
AddFlag
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Great!
it worked perfectly, thanks a lot!
I just had to change the condition in the fnFlag function
FilterNull = Table.SelectRows(Source, each (Number.IsNaN([value])))
@Anonymous what is the logic to filter? if any id has nan then filter that id?
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
yes, that was exactly the logic, thanks!
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 75 | |
| 36 | |
| 31 | |
| 29 | |
| 26 |