Child pages
  • API - FAQ - Usage in Excel Power Query

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Further in this page, there is an example on how the refresh date can be made visible.

In case you need to work , not with the lastest latest data , but a specific data extraction. it is recommended to work with files you downloaded from the API and organised in your storage that can eventually be loaded as CSV File within Excel.

In this case the extraction date could be set as the file modified date as provided by the operating system. Please see below on how to retrieve this information from Excel Power Query

...

It is possible to build an API link to download SDMX-CSV-2.0 data for a dataset via the Databrowser download options menu.

...

This load the Power Query Editor with an initial Source   Source step configured 

Code Block
= Web.Contents("https://ec.europa.eu/eurostat/api/dissemination/sdmx/3.0/data/dataflow/ESTAT/ISOC_CI_ID_H/1.0?format=csvdata&formatVersion=2.0&compress=false")

...

Info

While this guide try to minimize minimise the need to edit the formula as much as possible, for daily use it is recommended to use compressed input by

  • removing the &compress=false parameter in the URL
  • wrapping the Web.Contents into a Binary.Decompress() method for GZIP uncompression
Code Block
= Binary.Decompress(Web.Contents("https://ec.europa.eu/eurostat/api/dissemination/sdmx/3.0/data/dataflow/ESTAT/ISOC_CI_ID_H/1.0?format=csvdata&formatVersion=2.0"),Compression.GZip)

...

Complete result of this step as visible in the Advanced Editor

(lightbulb) This code can be copy pasted pasted

Code Block
let
    Source = Binary.Decompress(Web.Contents("https://ec.europa.eu/eurostat/api/dissemination/sdmx/3.0/data/dataflow/ESTAT/ISOC_CI_ID_H/1.0?format=csvdata&formatVersion=2.0"),Compression.GZip),
    #"Imported CSV" = Csv.Document(Source,[Delimiter=",", Columns=10, Encoding=1252, QuoteStyle=QuoteStyle.None]),
    #"Promoted Headers" = Table.PromoteHeaders(#"Imported CSV", [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"STRUCTURE", type text}, {"STRUCTURE_ID", type text}, {"freq", type text}, {"indic_is", type text}, {"unit", type text}, {"hhtyp", type text}, {"geo", type text}, {"TIME_PERIOD", Int64.Type}, {"OBS_VALUE", Int64.Type}, {"OBS_FLAG", type text}}, "en-150"),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"STRUCTURE", "STRUCTURE_ID"})
in
    #"Removed Columns"

...

There are 2 options to enable on the initial data query that could enpower empower further data rendering in Excel

...

This column can be moved by Drag and Drop before the others,  this action is recorded as a ReoderColumns  ReorderColumns action in the query definition

...

It is possible to build an API link to download TSV 2.0 data for a dataset via the Databrowser download options menu.

...

Info

While this guide try to minimize minimise the need to edit the formula as much as possible, for daily use it is recommended to use compressed input by

  • removing the &compress=false parameter in the URL
  • wrapping the Web.Contents into a Binary.Decompress() method for GZIP uncompression
Code Block
= Binary.Decompress(Web.Contents("https://ec.europa.eu/eurostat/api/dissemination/sdmx/3.0/data/dataflow/ESTAT/ISOC_CI_ID_H/1.0?format=TSV"),Compression.GZip)

...

Recommended way to add labelling on top of TSV data is to load it from the accompanying codelistscode lists. Power Query make this quite easy by allowing to combine several queries

First step is to define several queries to load the data and the necessary codelistscode lists

Then the data table must be combined with the FREQ dimension, the result of this combination must be combined with INDIC_IS dimension etc

To combine two queries, a new query must be created from Power Query Editor and select the column in each table to use to JOIN them. The Join Kind must be Left Outer to execute the lookup properly 

...

When all labels columns are created they can be moved to be next to the code column

All these steps are summarized summarised in the following workbook and codeblockcode sample

View file
nameTSV-ISOC.xlsx
height250

...

Tip
titleShare data queries

Option 1 : Copy several queries between workbooks and share workbook files

Starting from a blank worksheet, it is possible to re-use existing queries from another workbook


Create a new worksheet

Reveal the Queries & Connections  

Right-click under the queries pane and click Paste

This will automatically load the last query into the current worksheet 


Option 2 : Export and share ODC files

When a query is completed, it is possible to select the final query to be exported as an ODC file as the one below

View file
nameTSV-ISOC-WITH-LABELS.odc
height250

This file can be simply double-clicked on windows and should open in Excel directly.

Otherwise it can be loaded as an existing connection

This menu automatically list connections present in the "My Data Sources" user folder C:\Users\user_id\Documents\My Data Sources

Files in another location can be opened with the Browser Browse for more more button.

More information on ODC files from Microsoft documentation

...