JackDanIce
Well-known Member
- Joined
- Feb 3, 2010
- Messages
- 9,922
- Office Version
- 365
- Platform
- Windows
Hi,
This is my current script/applied steps to import data from the spreadsheet and reduce it to latest week:
Via Source, WeekNum are calculated by today's date so the column is always in descending order.
I believe I've defined the WeekNum column correctly as integer but I think I'm using List.Max incorrectly and guessing a separate function needs to be used?
Error with line: #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [WeekNum] = List.Max([WeekNum]))
Bold part is what I've changed and it's generating error:
Expression.Error: We cannot convert the value 37 to type List.
Details:
Value=37
Type=[Type]
Alternatively, return the value of the last row in WeekNum and filter by that column
Searching online keeps bringing up answers that create another column but I do not think that's needed for this, can anyone help with a suggestion, preference find max of the column?
TIA,
Jack
This is my current script/applied steps to import data from the spreadsheet and reduce it to latest week:
Power Query:
let
Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
#"Removed Columns" = Table.RemoveColumns(Source,{"Monday", "Open", "Close", "Size", "Ribbon", "TimeFrame", "B1", "B2", "B3", "B4", "123 Shape", "1-3 Time Gap", "123 vs Red Pivot", "123 vs Yellow Pivot", "3 Close to Ribbon", "Comment"}),
#"Changed Type" = Table.TransformColumnTypes(#"Removed Columns",{{"Date", type date},{"WeekNum", Int64.Type}, {"Security", type text}, {"Direction", type text}, {"Open", type number}, {"Stop", type number}, {"Target", type number}, {"R", Int64.Type}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each [WeekNum] = List.Max([WeekNum])),
#"Filter and Drop WeekNum" = Table.RemoveColumns(#"Filtered Rows",{"WeekNum"})
in
#"Filter and Drop WeekNum"
Via Source, WeekNum are calculated by today's date so the column is always in descending order.
I believe I've defined the WeekNum column correctly as integer but I think I'm using List.Max incorrectly and guessing a separate function needs to be used?
Error with line: #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [WeekNum] = List.Max([WeekNum]))
Bold part is what I've changed and it's generating error:
Expression.Error: We cannot convert the value 37 to type List.
Details:
Value=37
Type=[Type]
Alternatively, return the value of the last row in WeekNum and filter by that column
Searching online keeps bringing up answers that create another column but I do not think that's needed for this, can anyone help with a suggestion, preference find max of the column?
TIA,
Jack