Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello everyone,
I'm new with power bi,
I would like to dynamically erase these lines in yellow non power query, how do I do that?
link file:
Solved! Go to Solution.
The key here is to find the maximal 0 row for each index run and then keep only the rows with an index greater or equal to the maximal zero row index.
Here's sample code for your example that you can paste into the Advanced Editor of a new blank query:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ddPLFYQgDAXQXly7IF+wFo/9tzESgkJwFuIZvQTIc85zA+B8bPsG9RKkdN/rhamOkGA/5EB7eO03RwQIHFDuUZrnHdv7rmNx0GJw4ti5SOAo9n7S1HVJUWtetsKPjrUJqqZJi2tKJWq2+XNxdc4SuYLa9p821p/5L8+qa1vKX16s+lz86Lp1tGLBN8+R9jAFA7W5NkDCIcfMAbaZZJCGBK38CHFd3fOjZXX7kABH6+mxNSYeSibq0TFGaudRetLz0Fgi/NirJ8b6tf5MPS1ZjtUefGUlGPtq28TxH+iS4gbeqpgsMM9KlqwYlvXvJl/XDw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [code_operation = _t, branch = _t, code = _t, #"amount day" = _t, Amount = _t, price = _t, Index = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"code_operation", Int64.Type}, {"branch", Int64.Type}, {"code", Int64.Type}, {"amount day", Int64.Type}, {"Amount", Int64.Type}, {"price", Int64.Type}, {"Index", Int64.Type}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([amount day] = 0)),
#"Grouped Rows" = Table.Group(#"Filtered Rows", {"branch"}, {{"Max0", each List.Max([Index]), type nullable number}}),
#"Merged Queries" = Table.NestedJoin(#"Changed Type", {"branch"}, #"Grouped Rows", {"branch"}, "Grouped Rows", JoinKind.LeftOuter),
#"Expanded Grouped Rows" = Table.ExpandTableColumn(#"Merged Queries", "Grouped Rows", {"Max0"}, {"Max0"}),
#"Filtered Rows1" = Table.SelectRows(#"Expanded Grouped Rows", each ([Index] >= [Max0])),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows1",{"Max0"})
in
#"Removed Columns"
The key here is to find the maximal 0 row for each index run and then keep only the rows with an index greater or equal to the maximal zero row index.
Here's sample code for your example that you can paste into the Advanced Editor of a new blank query:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ddPLFYQgDAXQXly7IF+wFo/9tzESgkJwFuIZvQTIc85zA+B8bPsG9RKkdN/rhamOkGA/5EB7eO03RwQIHFDuUZrnHdv7rmNx0GJw4ti5SOAo9n7S1HVJUWtetsKPjrUJqqZJi2tKJWq2+XNxdc4SuYLa9p821p/5L8+qa1vKX16s+lz86Lp1tGLBN8+R9jAFA7W5NkDCIcfMAbaZZJCGBK38CHFd3fOjZXX7kABH6+mxNSYeSibq0TFGaudRetLz0Fgi/NirJ8b6tf5MPS1ZjtUefGUlGPtq28TxH+iS4gbeqpgsMM9KlqwYlvXvJl/XDw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [code_operation = _t, branch = _t, code = _t, #"amount day" = _t, Amount = _t, price = _t, Index = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"code_operation", Int64.Type}, {"branch", Int64.Type}, {"code", Int64.Type}, {"amount day", Int64.Type}, {"Amount", Int64.Type}, {"price", Int64.Type}, {"Index", Int64.Type}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([amount day] = 0)),
#"Grouped Rows" = Table.Group(#"Filtered Rows", {"branch"}, {{"Max0", each List.Max([Index]), type nullable number}}),
#"Merged Queries" = Table.NestedJoin(#"Changed Type", {"branch"}, #"Grouped Rows", {"branch"}, "Grouped Rows", JoinKind.LeftOuter),
#"Expanded Grouped Rows" = Table.ExpandTableColumn(#"Merged Queries", "Grouped Rows", {"Max0"}, {"Max0"}),
#"Filtered Rows1" = Table.SelectRows(#"Expanded Grouped Rows", each ([Index] >= [Max0])),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows1",{"Max0"})
in
#"Removed Columns"
great Alexis I'll test the code.
What will be the logic to capture these yellow rows?
Hi Vijay,
start cutting from the zero value in the index column and end it before the next zero value in the day quantity column, but this is only if there is more than one zero value in the day quantity column only.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
9 | |
9 | |
7 | |
6 | |
6 |