我在Power BI中有一个标准报告文件,需要定期添加更多行/记录。每个记录大约有8个属性。其他9个属性将被填充(或不填充),这取决于记录的类型。 我使用了 Table.InsertRows ,但找不到在该函数中将值(从0到10)传递给变量x的方法。 x表示新数据文件中记录的序列号。我的想法是将新数据的第一行添加到标准文件中,然后将第二,第三行添加到该文件中。
let
Source = Excel.Workbook(File.Contents("C:\Users\uic30477\Desktop\Musterfile test.xlsx"), null, true),
Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Type", type text}, {"General column1", Int64.Type}, {"General column2", Int64.Type}, {"General column3", Int64.Type}, {"General column4", Int64.Type}, {"General column5", Int64.Type}, {"General column6", Int64.Type}, {"General column7", Int64.Type}, {"General column8", Int64.Type}, {"CDF column1", Int64.Type}, {"CDF column2", Int64.Type}, {"CDF column3", Int64.Type}, {"Budget column1", Int64.Type}, {"Budget column2", Int64.Type}, {"Budget column3", Int64.Type}, {"Budget column4", Int64.Type}, {"Deliveries column1", Int64.Type}, {"Deliveries column2", Int64.Type}}),
Custom1 = List.Generate(
() => [x=0],
each [x]<=10,
each [x=[x]+1]
),
Table.InsertRows(#"Changed Type", 7, {[Type = #"Newdata"{x}[Type], General column1 = #"Newdata"{x}[General column1], General column2 = #"Newdata"{x}[General column2], General column3 = #"Newdata"{x}[General column3], General column4 = #"Newdata"{x}[General column4], General column5 = #"Newdata"{x}[General column5], General column6 = #"Newdata"{x}[General column6], General column7 = #"Newdata"{x}[General column7], General column8 = #"Newdata"{x}[General column8], CDF column1 = #"Newdata"{x}[CDF column1], CDF column2 = #"Newdata"{x}[CDF column2], CDF column3 = #"Newdata"{x}[CDF column3], Budget column1 = #"Newdata"{x}[Budget column1], Budget column2 = #"Newdata"{x}[Budget column2], Budget column3 = #"Newdata"{x}[Budget column3], Budget column4 = #"Newdata"{x}[Budget column4], Deliveries column1 = #"Newdata"{x}[Deliveries column1], Deliveries column2 = #"Newdata"{x}[Deliveries column2]]})
in
Custom1
我是这种语言的新手。任何建议或其他插入新记录的方式对我来说都是非常有用的。 谢谢!