Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowData Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more
Hi Folks,
I'm trying to filter every 3 last months > 0.
e.g.:
The last three months to "DEF" was 0. I need to remove it from my table.
Any ideias?
Ty guys!!
Solved! Go to Solution.
Try this code @Anonymous
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc49DoAgDIbhu3QmKVAjOKr4dwbC/a8hoUvN5/INz/C2tVJiCRx9DORo3fa+npqrlMHj8IXFf12G2045zt+OdduxbjvX/fTN0FFP0FHXzgx/TuB6F1073dsL", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Attribute = _t, Value = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Value", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Prev3Mo", each Date.IsInPreviousNMonths([Date],3)),
#"Grouped Rows" = Table.Group(#"Added Custom", {"Attribute", "Prev3Mo"}, {{"Total", each List.Sum([Value]), type nullable number}, {"All Rows", each _, type table [Date=nullable date, Attribute=nullable text, Value=nullable number, Prev3Mo=logical]}}),
#"Filtered Rows" = Table.SelectRows(#"Grouped Rows", each ([Total] <> 0)),
#"Expanded All Rows" = Table.ExpandTableColumn(#"Filtered Rows", "All Rows", {"Date", "Value"}, {"Date", "Value"}),
#"Removed Columns" = Table.RemoveColumns(#"Expanded All Rows",{"Total", "Prev3Mo"}),
#"Reordered Columns" = Table.ReorderColumns(#"Removed Columns",{"Date", "Attribute", "Value"})
in
#"Reordered Columns"
It turns this:
into this
What I did is this:
How to use M code provided in a blank query:
1) In Power Query, select New Source, then Blank Query
2) On the Home ribbon, select "Advanced Editor" button
3) Remove everything you see, then paste the M code I've given you in that box.
4) Press Done
5) See this article if you need help using this M code in your model.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingTry this code @Anonymous
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc49DoAgDIbhu3QmKVAjOKr4dwbC/a8hoUvN5/INz/C2tVJiCRx9DORo3fa+npqrlMHj8IXFf12G2045zt+OdduxbjvX/fTN0FFP0FHXzgx/TuB6F1073dsL", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Attribute = _t, Value = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Value", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Prev3Mo", each Date.IsInPreviousNMonths([Date],3)),
#"Grouped Rows" = Table.Group(#"Added Custom", {"Attribute", "Prev3Mo"}, {{"Total", each List.Sum([Value]), type nullable number}, {"All Rows", each _, type table [Date=nullable date, Attribute=nullable text, Value=nullable number, Prev3Mo=logical]}}),
#"Filtered Rows" = Table.SelectRows(#"Grouped Rows", each ([Total] <> 0)),
#"Expanded All Rows" = Table.ExpandTableColumn(#"Filtered Rows", "All Rows", {"Date", "Value"}, {"Date", "Value"}),
#"Removed Columns" = Table.RemoveColumns(#"Expanded All Rows",{"Total", "Prev3Mo"}),
#"Reordered Columns" = Table.ReorderColumns(#"Removed Columns",{"Date", "Attribute", "Value"})
in
#"Reordered Columns"
It turns this:
into this
What I did is this:
How to use M code provided in a blank query:
1) In Power Query, select New Source, then Blank Query
2) On the Home ribbon, select "Advanced Editor" button
3) Remove everything you see, then paste the M code I've given you in that box.
4) Press Done
5) See this article if you need help using this M code in your model.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingShould be simple enough.
Got any sample data (not a screenshot)?
And perhaps your current M code from your queries?
| Have I solved your problem? Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;). |
Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.
Check out the May 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 1 |
| User | Count |
|---|---|
| 11 | |
| 11 | |
| 5 | |
| 4 | |
| 4 |