Join 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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I have the following set up and in #"Filtered Rows" I am trying to get the top 4 values returned. With the code I have below, it is returning an empty table and I haven't been able to figure out what is broken. Any guidance would be greatly appreciated. Thank you!
let
Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Fiscal Year Week", type number}, {"Customer Number", Int64.Type}, {"PIM Superclass", type text}, {"Sales $", type number}, {"LY", type number}, {"Var", type number}, {"Var %", type number}, {"AOP", type any}, {"Var2", type any}, {"Cases", type number}, {"LY3", type number}, {"Var4", type number}, {"Var %5", type number}, {"AOP6", type any}, {"Var7", type any}, {"Gross TGP", type number}, {"LY8", type number}, {"Var9", type number}, {"Var %10", type number}, {"AOP11", type any}, {"Var12", type any}, {"Gross TGP %", type number}, {"LY13", type number}, {"Var14", type number}, {"AOP15", type any}, {"Var16", type any}, {"SAGP", type number}, {"LY17", type number}, {"Var18", type number}, {" Var %", type number}, {"SAGP %", type number}, {"LY19", type number}, {"Var20", type number}, {"Net Accounts", Int64.Type}, {"LY21", Int64.Type}, {"Var22", Int64.Type}, {"Var %23", Int64.Type}, {"Gross TGP+PA per Drop", type number}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Fiscal Year Week", "Customer Number"}, {{"Sales $", each List.Sum([#"Sales $"]), type nullable number}, {"Cases", each List.Sum([Cases]), type nullable number}}),
#"Filtered Rows" = Table.SelectRows(#"Grouped Rows", each ([Fiscal Year Week] = List.MaxN(#"Grouped Rows"[Fiscal Year Week],4))),
#"Grouped Rows1" = Table.Group(#"Filtered Rows", {"Customer Number"}, {{"Sales $", each List.Sum([#"Sales $"]), type nullable number}, {"Cases", each List.Sum([Cases]), type nullable number}}),
#"Divided Column" = Table.TransformColumns(#"Grouped Rows1", {{"Sales $", each _ / 4, type number}}),
#"Divided Column1" = Table.TransformColumns(#"Divided Column", {{"Cases", each _ / 4, type number}}),
#"Renamed Columns" = Table.RenameColumns(#"Divided Column1",{{"Sales $", "4 Week Avg Weekly Sales $"}, {"Cases", "4 Week Avg Weekly Cases"}})
in
#"Renamed Columns"
@amitchandak I looked through this and not sure that it will work for my needs as I am trying to do this for a dynamic data set that won't always have the the same max values in the [Fiscal Year Week] column.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 59 | |
| 43 | |
| 42 | |
| 23 | |
| 17 |
| User | Count |
|---|---|
| 190 | |
| 122 | |
| 96 | |
| 66 | |
| 47 |