gpt4 book ai didi

google-analytics - 从Google Analytics(分析)向Power Query添加列

转载 作者:行者123 更新时间:2023-12-03 16:17:32 26 4
gpt4 key购买 nike

我正在使用Kohera的Power Pivot公式在Power Query中获取Google Analytics(分析)数据:


analytics = "https://www.googleapis.com/analytics/v3/data/ga?access_token=",
addAccessToken = analytics &
Excel.CurrentWorkbook(){[Name="TblToken"]}[Content]{0}[Access Token],
addViewId = addAccessToken & "&ids=ga:33784873",
addStartDate = addViewId & "&start-date=2014-10-01",
addEndDate = addStartDate & "&end-date=2014-12-31",
addDimensions = addEndDate & "&dimensions=ga:operatingSystem",
url = addDimensions & "&metrics=ga:sessions",
GaJson = Json.Document(Web.Contents(url)),
GetRows = GaJson[rows],
TableFromList = Table.FromList(GetRows, Splitter.SplitByNothing(),
null, null, ExtraValues.Error),
ColOS = Table.AddColumn(TableFromList, "OS", each [Column1]{0}),
ColCount = Table.AddColumn(ColOS, "Count", each [Column1]{1}),
RemoveFirstColumn = Table.RemoveColumns(ColCount,{"Column1"}) in RemoveFirstColumn


但是,如何添加更多列?例如,如果我想查询ga:hostname,ga:country,ga:browser,如何在M代码中得到它?
谢谢!

最佳答案

好,我知道了。为他人解释:

    TableFromList = Table.FromList(GetRows, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
ColHostname = Table.AddColumn(TableFromList, "Hostname", each [Column1]{0}),
ColCountry = Table.AddColumn(ColHostname, "Country", each [Column1]{1}),
ColBrowser = Table.AddColumn(ColCountry, "Browser", each [Column1]{2}),
ColCount = Table.AddColumn(ColBrowser, "Count", each [Column1]{3}),
RemoveFirstColumn = Table.RemoveColumns(ColCount,{"Column1"})

关于google-analytics - 从Google Analytics(分析)向Power Query添加列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37045282/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com