Forum Discussion
We cannot convert the value to type List.
I am creating a calculated column and getting error. "We cannot convert the value 98112 to type List."
My M Query program.
let
Source = Excel.Workbook(File.Contents("C:\Users\ssneg\OneDrive\Desktop\Microsoft\Customers.xlsx"), null, true),
Customers_Sheet = Source{[Item="Customers",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Customers_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Customer ID", Int64.Type}, {"Name", type text}, {"Phone", type text}, {"Address", type text}, {"City", type text}, {"State", type text}, {"Zip", Int64.Type}, {"Country", type text}, {"Notes", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "ZipCalc", each [Zip] * 10),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "AvgCalc", each List.Max([Zip],[ZipCalc])),
#"Changed Type2" = Table.TransformColumnTypes(#"Added Custom1",{{"Zip", type any}, {"AvgCalc", Decimal.Type}})
in
#"Changed Type2"
Hi ssnegi1971 It is expecting a list as an input that is why the error is being thrown try wrapping Zip and ZipCalc in {} at custom 1 step.... try this out please
let Source = Excel.Workbook(File.Contents("C:\Users\ssneg\OneDrive\Desktop\Microsoft\Customers.xlsx"), null, true), Customers_Sheet = Source{[Item="Customers",Kind="Sheet"]}[Data], #"Promoted Headers" = Table.PromoteHeaders(Customers_Sheet, [PromoteAllScalars=true]), #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Customer ID", Int64.Type}, {"Name", type text}, {"Phone", type text}, {"Address", type text}, {"City", type text}, {"State", type text}, {"Zip", Int64.Type}, {"Country", type text}, {"Notes", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "ZipCalc", each [Zip] * 10), #"Added Custom1" = Table.AddColumn(#"Added Custom", "AvgCalc", each List.Max({[Zip], [ZipCalc]})), // Wrap in {} #"Changed Type2" = Table.TransformColumnTypes(#"Added Custom1",{{"Zip", type any}, {"AvgCalc", Decimal.Type}}) in #"Changed Type2"If this post helped please do give a kudos and accept this as a solution
Thanks In Advance
2 Replies
- Akash_VarunaSuper User
Hi ssnegi1971 It is expecting a list as an input that is why the error is being thrown try wrapping Zip and ZipCalc in {} at custom 1 step.... try this out please
let Source = Excel.Workbook(File.Contents("C:\Users\ssneg\OneDrive\Desktop\Microsoft\Customers.xlsx"), null, true), Customers_Sheet = Source{[Item="Customers",Kind="Sheet"]}[Data], #"Promoted Headers" = Table.PromoteHeaders(Customers_Sheet, [PromoteAllScalars=true]), #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Customer ID", Int64.Type}, {"Name", type text}, {"Phone", type text}, {"Address", type text}, {"City", type text}, {"State", type text}, {"Zip", Int64.Type}, {"Country", type text}, {"Notes", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "ZipCalc", each [Zip] * 10), #"Added Custom1" = Table.AddColumn(#"Added Custom", "AvgCalc", each List.Max({[Zip], [ZipCalc]})), // Wrap in {} #"Changed Type2" = Table.TransformColumnTypes(#"Added Custom1",{{"Zip", type any}, {"AvgCalc", Decimal.Type}}) in #"Changed Type2"If this post helped please do give a kudos and accept this as a solution
Thanks In Advance - ssnegi1971Frequent Visitor
Thank you for the resolution. Very helpful.