Last active
October 25, 2024 13:46
-
-
Save alekrutkowski/3327f79c9f693e671f85e1e90785112f to your computer and use it in GitHub Desktop.
PoweQuery M example of importing data from Eurostat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let | |
Source = Csv.Document(Web.Contents("https://ec.europa.eu/eurostat/api/dissemination/sdmx/3.0/data/dataflow/ESTAT" & | |
"/nama_10_gdp/1.0/*?" & // ← modify dataset | |
// ↓ modify dimensions and their values | |
"c[unit]=CP_MEUR&c[na_item]=B1GQ,P3&c[geo]=EU27_2020,EA20" & | |
"&compress=false&format=csvdata&formatVersion=2.0&" & | |
"c[TIME_PERIOD]=ge:2021+le:2023"), // ← modify time span | |
[Delimiter=",", | |
Encoding=65001, QuoteStyle=QuoteStyle.None]), | |
PromotedHeaders = Table.PromoteHeaders(Source, [PromoteAllScalars=true]), | |
ChangedType = Table.TransformColumnTypes(PromotedHeaders,{{"STRUCTURE", type text}, {"STRUCTURE_ID", type text}, {"freq", type text}, | |
// ↓ this line likely to be modified | |
{"unit", type text}, {"na_item", type text}, {"geo", type text}, {"TIME_PERIOD", Int64.Type}, | |
{"OBS_VALUE", Int64.Type}, {"OBS_FLAG", type text}}), | |
CombinedVariableName = Table.AddColumn(ChangedType, "Variables", | |
each Text.Combine({[na_item], " ", [unit]})), // ← this line likely to be modified | |
SelectedColumns = Table.SelectColumns(CombinedVariableName, {"geo", "TIME_PERIOD", // ← this line likely to be modified | |
"OBS_VALUE","Variables"}), | |
PivotedColumn = Table.Pivot(SelectedColumns, List.Distinct(SelectedColumns[Variables]), "Variables", "OBS_VALUE") | |
in | |
PivotedColumn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment