我的目标是拥有像这样的数据源
从类似于此的json文件(实际上它是一个具有更多属性的geojson文件,但这是结构):
{
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"id": 1,
"geometry": {
"type": "Point",
"coordinates": ".."
},
"properties": {
"ProjectNr": "001",
"ProjectName": "Proj1"
}
},
{
"type": "Feature",
"id": 2,
"geometry": {
"type": "Point",
"coordinates": ".."
},
"properties": {
"ProjectNr": "002",
"ProjectName": "Proj2"
}
}
]
}
所以步骤是从 features 属性创建一个表,但是从属性对象中获取列名和实际行嵌套的级别更深。
我可以在查询编辑器中找到包含这些步骤的单行表:
这在高级编辑器中显示为:
let
Source = Json.Document(File.Contents(".\projekter.api.geojson")),
features = Source[features],
#"Converted to Table" = Table.FromList(features, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
Column1 = #"Converted to Table"{0}[Column1],
properties = Column1[properties],
#"Converted to Table1" = Record.ToTable(properties),
#"Transposed Table" = Table.Transpose(#"Converted to Table1"),
#"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"ProjektNr", type text}, {"ProjektNavn", type text}, {"ProjektBeskrivelse", type text}, {"AnlaegsBeloeb", Int64.Type}, {"BudgetUdgift", Int64.Type}, {"BudgetIndtaegt", Int64.Type}, {"BudgetAar", Int64.Type}, {"ProjektlederNavn", type text}, {"ForventetAnlaegStart", type datetime}, {"ForventetAnlaegSlut", type datetime}, {"ForventetProjekteringStart", type datetime}, {"ForventetProjekteringSlut", type datetime}, {"ProjektfaseBetegnelse", type text}, {"ProjektkategoriBetegnelse", type text}, {"ProjekttypeBetegnelse", type text}, {"StrategiBetegnelse", type text}, {"HjemmesideLink", type text}})
in
#"Changed Type"
这需要从功能创建一个表,然后导航到第一个记录并修改结构以获得正确的布局,但我无法弄清楚如何为每一行重复类似的过程,或者如果我在吠叫在这个错误的树上。
答案 0 :(得分:0)
获得详细信息行的解决方案后,您可以将整个代码转换为函数。然后可以在表的每一行调用此函数。
创建一个功能。 考虑您有以下查询(高级编辑器):
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(PATH_TO_OUTPUT_FILE));
Document layoutDocument = new Document(pdfDocument);
Paragraph portfolioText = new Paragraph("View our Portfolio");
portfolioText.setFont(PdfFontFactory.createFont());
portfolioText.setFontColor(Color.ORANGE);
portfolioText.setFixedLeading(12.1f);
portfolioText.setFirstLineIndent(90f);
portfolioText.setAction(PdfAction.createURI("http://google.com/"));
layoutDocument.add(portfolioText);
layoutDocument.close();
你可以创建一个函数,并给出参数。 (在这个例子中说明)
只需在前一段代码中添加另一个let和In语句。
let
Source = Text.PadStart(Text.From(Date.Month(InDate)),2,"0") &
"/" & Text.PadStart(Text.From(Date.Day(InDate)),2,"0") & "/"
&Text.From(Date.Year(InDate))
in
Source
in
FormatDate
调用此功能可以通过添加自定义列来完成。