I am having an issue w/ my below M Code. I have set up an simple example of what i am trying to do below, but know the issue is when try to append variable dates as headers into the table:
The table starts like table A. I use some simple query functions to get to this point. But I need to add the columns w/ dates and the function (Table A: Total Qty/50) for all added date columns as in Table B.
[TABLE="width: 576"]
<tbody>[TR]
[TD]Table A[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Product[/TD]
[TD]Table A: Total Qty[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]a[/TD]
[TD="align: right"]323000[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]b[/TD]
[TD="align: right"]898807[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]c[/TD]
[TD="align: right"]844945[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]d[/TD]
[TD="align: right"]36330[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]e[/TD]
[TD="align: right"]281009[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]f[/TD]
[TD="align: right"]611092[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]g[/TD]
[TD="align: right"]633217[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Table B[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Product[/TD]
[TD]Table A: Total Qty[/TD]
[TD="align: right"]6/4/2017[/TD]
[TD="align: right"]6/11/2017[/TD]
[TD="align: right"]6/18/2017[/TD]
[TD="align: right"]6/25/2017[/TD]
[TD="align: right"]7/2/2017[/TD]
[TD="align: right"]7/9/2017[/TD]
[/TR]
[TR]
[TD]a[/TD]
[TD] 323,000[/TD]
[TD] 6,460[/TD]
[TD] 6,460[/TD]
[TD] 6,460[/TD]
[TD] 6,460[/TD]
[TD] 6,460[/TD]
[TD] 6,460[/TD]
[/TR]
[TR]
[TD]b[/TD]
[TD] 898,807[/TD]
[TD] 17,976[/TD]
[TD] 17,976[/TD]
[TD] 17,976[/TD]
[TD] 17,976[/TD]
[TD] 17,976[/TD]
[TD] 17,976[/TD]
[/TR]
[TR]
[TD]c[/TD]
[TD] 844,945[/TD]
[TD] 16,899[/TD]
[TD] 16,899[/TD]
[TD] 16,899[/TD]
[TD] 16,899[/TD]
[TD] 16,899[/TD]
[TD] 16,899[/TD]
[/TR]
[TR]
[TD]d[/TD]
[TD] 36,330[/TD]
[TD] 727[/TD]
[TD] 727[/TD]
[TD] 727[/TD]
[TD] 727[/TD]
[TD] 727[/TD]
[TD] 727[/TD]
[/TR]
[TR]
[TD]e[/TD]
[TD] 281,009[/TD]
[TD] 5,620[/TD]
[TD] 5,620[/TD]
[TD] 5,620[/TD]
[TD] 5,620[/TD]
[TD] 5,620[/TD]
[TD] 5,620[/TD]
[/TR]
[TR]
[TD]f[/TD]
[TD] 611,092[/TD]
[TD] 12,222[/TD]
[TD] 12,222[/TD]
[TD] 12,222[/TD]
[TD] 12,222[/TD]
[TD] 12,222[/TD]
[TD] 12,222[/TD]
[/TR]
[TR]
[TD]g[/TD]
[TD] 633,217[/TD]
[TD] 12,664[/TD]
[TD] 12,664[/TD]
[TD] 12,664[/TD]
[TD] 12,664[/TD]
[TD] 12,664[/TD]
[TD] 12,664[/TD]
[/TR]
</tbody>[/TABLE]
Hope you can help! Thanks in advance!
Alex
Code:
let
Set up steps.
.
.
.
#"Appended Query" = Table.Combine({#"Removed Other Columns",Table.PromoteHeaders(Table.Transpose(Table.FromList(List.Dates(Date.StartOfWeek(DateTime.Date(DateTime.LocalNow()), Day.Sunday), 52, #duration(7,0,0,0)), Splitter.SplitByNothing(), {"Dates"}, null, ExtraValues.Error)),[PromoteAllScalars=true])})
in
#"Appended Query"
Code:
Error:
Expression.Error: 2 arguments were passed to a function which expects 1.
Details:
Pattern=
Arguments=List
The table starts like table A. I use some simple query functions to get to this point. But I need to add the columns w/ dates and the function (Table A: Total Qty/50) for all added date columns as in Table B.
[TABLE="width: 576"]
<tbody>[TR]
[TD]Table A[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Product[/TD]
[TD]Table A: Total Qty[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]a[/TD]
[TD="align: right"]323000[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]b[/TD]
[TD="align: right"]898807[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]c[/TD]
[TD="align: right"]844945[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]d[/TD]
[TD="align: right"]36330[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]e[/TD]
[TD="align: right"]281009[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]f[/TD]
[TD="align: right"]611092[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]g[/TD]
[TD="align: right"]633217[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Table B[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Product[/TD]
[TD]Table A: Total Qty[/TD]
[TD="align: right"]6/4/2017[/TD]
[TD="align: right"]6/11/2017[/TD]
[TD="align: right"]6/18/2017[/TD]
[TD="align: right"]6/25/2017[/TD]
[TD="align: right"]7/2/2017[/TD]
[TD="align: right"]7/9/2017[/TD]
[/TR]
[TR]
[TD]a[/TD]
[TD] 323,000[/TD]
[TD] 6,460[/TD]
[TD] 6,460[/TD]
[TD] 6,460[/TD]
[TD] 6,460[/TD]
[TD] 6,460[/TD]
[TD] 6,460[/TD]
[/TR]
[TR]
[TD]b[/TD]
[TD] 898,807[/TD]
[TD] 17,976[/TD]
[TD] 17,976[/TD]
[TD] 17,976[/TD]
[TD] 17,976[/TD]
[TD] 17,976[/TD]
[TD] 17,976[/TD]
[/TR]
[TR]
[TD]c[/TD]
[TD] 844,945[/TD]
[TD] 16,899[/TD]
[TD] 16,899[/TD]
[TD] 16,899[/TD]
[TD] 16,899[/TD]
[TD] 16,899[/TD]
[TD] 16,899[/TD]
[/TR]
[TR]
[TD]d[/TD]
[TD] 36,330[/TD]
[TD] 727[/TD]
[TD] 727[/TD]
[TD] 727[/TD]
[TD] 727[/TD]
[TD] 727[/TD]
[TD] 727[/TD]
[/TR]
[TR]
[TD]e[/TD]
[TD] 281,009[/TD]
[TD] 5,620[/TD]
[TD] 5,620[/TD]
[TD] 5,620[/TD]
[TD] 5,620[/TD]
[TD] 5,620[/TD]
[TD] 5,620[/TD]
[/TR]
[TR]
[TD]f[/TD]
[TD] 611,092[/TD]
[TD] 12,222[/TD]
[TD] 12,222[/TD]
[TD] 12,222[/TD]
[TD] 12,222[/TD]
[TD] 12,222[/TD]
[TD] 12,222[/TD]
[/TR]
[TR]
[TD]g[/TD]
[TD] 633,217[/TD]
[TD] 12,664[/TD]
[TD] 12,664[/TD]
[TD] 12,664[/TD]
[TD] 12,664[/TD]
[TD] 12,664[/TD]
[TD] 12,664[/TD]
[/TR]
</tbody>[/TABLE]
Hope you can help! Thanks in advance!
Alex