40
CartONG – 23 boulevard du musée, 73000 Chambéry – France www.cartong.org | [email protected] [email protected] | www.cartong.org Page 1 | 40 POWER BI USER GUIDE Lessons learned from a UNHCR-CartONG Power BI project: different ways of connecting to various sources, of cleaning the data structure and of creating reports for further publishing or sharing. Legend: screenshot of the Power BI Dashboard on Anthropometry and Public Health data built by CartONG in support of UNHCR, which can be consulted here: http://sens.unhcr.org/data- dashboard/anthropometry-and-health/

Power BI User Guide - CartONG

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Power BI User Guide - CartONG

CartONG – 23 boulevard du musée, 73000 Chambéry – France www.cartong.org | [email protected]

[email protected] | www.cartong.org Page 1 | 40

POWER BI USER GUIDE

Lessons learned from a UNHCR-CartONG Power BI project: different ways of

connecting to various sources, of cleaning the data structure and of creating reports

for further publishing or sharing.

Legend: screenshot of the Power BI Dashboard on Anthropometry and Public Health data built

by CartONG in support of UNHCR, which can be consulted here: http://sens.unhcr.org/data-

dashboard/anthropometry-and-health/

Page 2: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 2 | 40

This publication has been produced with the assistance of the Office of

the United Nations High Commissioner for Refugees (UNHCR). The

content of this publication is the sole responsibility of CartONG and is not reflecting the views of

UNHCR in any way.

This publication is supported by the French Development Agency (AFD).

Nevertheless, the ideas and opinions presented in this document do not

necessarily represent those of AFD.

Page 3: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 3 | 40

Contents

Summary .................................................................................................................... 4

I. What are Power BI tools ......................................................................................... 4

I.1. General overview .............................................................................................. 4

I.2. PowerBI Desktop Workflow .............................................................................. 5

II. Connecting Power BI ............................................................................................. 5

II.1. Type of Data Source ........................................................................................ 5

II.2. Data Source Connection Workflow .................................................................. 6

II.3. Connecting an Excel file stored on cloud-based service ................................... 7

II.3.A. Dropbox ....................................................................................................... 7

II.3.B. Google Drive ................................................................................................. 9

II.3.C. OneDrive .................................................................................................... 10

II.3.D. Sharepoint ................................................................................................. 12

II.4. Connecting Enketo form on Kobotoolbox ....................................................... 14

II.4.A. Find Kobo project ID through Power BI Desktop .............................................. 14

II.4.B. Get form data ............................................................................................. 14

II.4.C. Get form labels instead of code ..................................................................... 15

II.5 Connecting Database ...................................................................................... 16

II.6 Comparison table ........................................................................................... 19

III. Preparing an Excel data ..................................................................................... 20

III.1. The list of recommendations ........................................................................ 20

III.2. Working on the modified structure of Excel database .................................. 22

III.3. How manually add or update the data ......................................................... 23

III.3.A. Generate key ............................................................................................. 23

III.3.B. Fill in with data all sheets ............................................................................ 24

III.3.C. How to modify a Cascading list .................................................................... 24

III.4. How to import data ...................................................................................... 26

III.4.A. Load data from KoboToolbox ....................................................................... 26

III.4.B. Upload data to Excel database ..................................................................... 28

III.5. How to filter data across the tabs ................................................................ 28

IV. Cleaning and transformation of Kobo data .......................................................... 29

IV.1. List of transformations ................................................................................. 29

IV.2. Direct connection to ArgGIS ......................................................................... 31

V. Publish dashboard from PowerBI desktop to PowerBI service ............................. 38

Page 4: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 4 | 40

Summary

Microsoft Power BI is a powerful analytical platform that provides the user with tools for

analyzing, visualizing, and sharing data.

The main purpose of this document is to present the different ways of connecting to various

sources, cleaning the data structure, and creating the report for further publishing to the web

and sharing with the colleagues.

I. What are Power BI tools

I.1. General overview

Power BI includes Power BI Desktop, Power BI Service, and PowerBI Mobile. Power BI

desktop is the Windows-desktop-based application for PCs and desktops. Power BI Service is

the online service accessed via PowerBI.com. Also, Power BI offers a set of mobile apps for iOS,

Android, and Windows 10 mobile devices. In mobile apps, you connect to and interact with your

cloud and on-premises data.

Power BI Desktop works in conjunction with the Power BI Service. Power BI Desktop allows

you to do the following:

● Get the data from a variety of sources

● Create relationships between your data and enrich your data model

● Create and save your reports

● Upload or publish your reports and share them with your colleagues.

It’s recommended to use the PowerBI Desktop for creating reports/dashboards and Power

BI service for publishing to the web and sharing a dashboard with others.

Page 5: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 5 | 40

I.2. PowerBI Desktop Workflow

There are three main core areas in PowerBI Desktop:

Data Preparation

Data Modeling

Data Visualization

The data preparation part includes the ways of connecting the source files with the Query

Editor and working with this data to get the actual dataset, the data we want to analyze later.

The data is loaded from Query Editor to Data model.

The Data model consists of two parts: Data Modeling and Data Visualization. Data Modeling

is performed in Data View and Relationship View. Data Modeling is the part where the data

analysis takes place and all the visuals are added.

II. Connecting Power BI

II.1. Type of Data Source

PowerBI Desktop allows to connect to data from many different sources:

File, such as excel, text/CSV, XML, JSON;

Database, such as SQL Server Database, Postgresql Database, Access Database;

Online services, such as SharePoint Online List, Microsoft Exchange Online, Google

Analytics;

Data collection platform, such as KoboToolbox, SurveyCTO.

This document contains examples of connecting:

Excel file saved on cloud-based services to Power BI:

Dropbox

Google Sheet

OneDrive

Page 6: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 6 | 40

Sharepoint

Xls form on Kobotoolbox

PostgreSQL Database

It’s essential to understand the performance of each data source and also connection

methods, report, and dashboard creation and the most important how easily data updates from

the data source

II.2. Data Source Connection Workflow

The following diagram presents the data source connection workflow from the data

preparation in PowerBI Desktop to Publishing the report to the web and scheduling the Refresh

in PowerBI Service. All of the steps are explained for each data source in the further sections.

The common steps which could be applied for all data source:

1) Hosting the file

2) Data preparation (PowerBI Desktop)

Building an URL by following the template

Transforming data

Data processing

3) Creating a report (PowerBI Desktop)

4) Publishing a report to the web (PowerBI Service)

5) Scheduling Refresh (PowerBI Service)

Page 7: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 7 | 40

II.3. Connecting an Excel file stored on cloud-based service

It’s highly recommended to modify the structure of Excel database based on recommendations

in the section “Preparing an Excel Data”

II.3.A. Dropbox

More information on Dropbox

Perform the following steps to connect an excel file hosted in Dropbox to Power BI

Desktop/Service

1. Save your file on Dropbox and choose Share > Copy link

2. Paste the link in any editor and replace the end dl=0 with dl=1

Example (Before)

https://www.dropbox.com/s/grs37xjc781ww1t/SENS%20Database.xlsx?dl=0

Example (After)

https://www.dropbox.com/s/grs37xjc781ww1t/SENS%20Database.xlsx?dl=1

3. Open Power BI desktop, click Get Data > From Web and copy the newly created

Url, then enter your credentials

4. The query is loaded

Page 8: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 8 | 40

5. Right-click on the file icon and choose Excel, then filter by column Name (select Table

1)

6. Click on Data column and choose to Remove Other Columns

7. Click on Expand

8. Clean the data and modify the data structure

9. Create a dashboard and publish to PowerBI (section “Publishing to PowerBI

service”)

10. Schedule Refresh (section “Schedule Refresh”)

Page 9: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 9 | 40

II.3.B. Google Drive

More information on Google Sheets

Perform the following steps to connect to an excel file hosted on Google Sheets to PowerBI

Desktop/Service

1. Load the excel file to your Google account

2. Open the file with Google Sheets

3. Select File > Publish to the Web

Entire Document

Microsoft Excel

4. Open PowerBI desktop, click Get Data > From Web and copy the new created Url

5. Select Database (out table is here) and load data

Page 10: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 10 | 40

6. Clean the data and modify the data structure

7. Create a dashboard and publish to PowerBI (section “Publishing to PowerBI service”)

8. Schedule Refresh (section “Schedule Refresh”)

II.3.C. OneDrive

More information on OneDrive Personal

Perform the following steps to connect excel file hosted on OneDrive Personal to PowerBI

Desktop/Service

1. Login into Microsoft 365, Open OneDrive and upload your excel file

The file should properly be formatted before loading to PowerBI, see the section “Prepare

Excel data for PowerBI.”

Page 11: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 11 | 40

2. Right-click on file and select Embed > Generate

3. Copy and save the information in separate file

Pay attention on resid, authkey, em, they will be used later

<iframe

src="https://onedrive.live.com/embed?cid=585B0518FADAEFFC&resid=585B0518FADAEF

FC%21118&authkey=AHFL6zTa7vk_M0w&em=2" width="402" height="346"

frameborder="0" scrolling="no"></iframe>

4. Please use the following format of the link to connect to excel file

https://onedrive.live.com/download?resid=585B0518FADAEFFC%21118&authkey=

AHFL6zTa7vk_M0w&em=2&app=HTML

5. Open PowerBI desktop and click Get Data > Web, copy newly created link

6. A select table where your data is stored and click Load

Page 12: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 12 | 40

7. Create a dashboard and publish to PowerBI (section “Publishing to PowerBI service”)

8. Schedule Refresh (section “Schedule Refresh”)

II.3.D. Sharepoint

Perform the following steps to connect excel file hosted on Sharepoint to PowerBI

Desktop/Service

1. Login into SharePoint account and upload your excel file

The file should properly be formatted before loading to PowerBI, see the section “Prepare

Excel data for PowerBI.”

2. Right-click on file and select Copy Link

Page 13: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 13 | 40

3. Copy and save the information in a separate file, and remove the highlighted parts

Example (Before)

https://actioncontrelafaim.sharepoint.com/:x:/r/sites/SiteName

/Shared%20Documents/Databases/Database.xlsx?d=we52fd5c34ff2419fa81c7c6194f2

f1aa&csf=1&web=1&e=mz1fnT

After

https://actioncontrelafaim.sharepoint.com/sites/SiteName

/Shared%20Documents/Databases/Database.xlsx

4. Open PowerBI desktop and click Get Data > Web, copy newly created link

5. A select table where your data is stored and click Load

6. Create a dashboard and publish to PowerBI (section “Publishing to PowerBI service”)

Page 14: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 14 | 40

7. Schedule Refresh (section “Schedule Refresh”)

II.4. Connecting Enketo form on Kobotoolbox

II.4.A. Find Kobo project ID through Power BI Desktop

1. Open PowerBI desktop and click Get Data > Web

2. Query your deployed forms using the URL of your Kobo instance API:

UNHCR - https://kobo.unhcr.org/

https://kobocat.unhcr.org/api/v1/data?format=csv

OCHA - https://kobo.humanitarianresponse.info/

https://kc.humanitarianresponse.info/api/v1/data?format=csv

Kobotoolbox - https://kf.kobotoolbox.org/

https://kc.kobotoolbox.org/api/v1/data?format=csv

3. Select Basic authentification and enter your Kobo Toolbox credentials correctly.

4. Get the ID from the list

II.4.B. Get form data

1. Select Get data > Web.

Page 15: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 15 | 40

2. Build the URL

Add form id from the previous section after “/data” preceded by a slash ( / ).

For example,

https://kobocat.unhcr.org/api/v1/data/16654?format=csv

3. Click OK, and the list of submissions will appear in a while.

4. Click Load

II.4.C. Get form labels instead of code

The steps below show how to find uuid for specific form on your Kobotoolbox

1. Log into your Kobotoolbox account

2. Choose the form and then click on Settings >Sharing

3. Click on Share by link and copy the uuid as shown in the screenshot below

Page 16: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 16 | 40

4. Once you get the uuid, you will need to repeat the steps mentioned in the section “Get

form data” by replacing URL with link template

https://kobocat.unhcr.org/username/reports/uuid/export.csv

II.5 Connecting Database

1. Set up the ssh tunnel

Note. This step requires additional configuration. Ask IT support for more details

Page 17: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 17 | 40

2. Open PowerBI desktop and click Get Data > More > ODBC

Note. ODBC needs to be installed in your computer

3. Prepare the string as shown below

Driver={PostgreSQL ANSI(x64)};Server=localhost;Port=Port;Database=Name;

Page 18: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 18 | 40

4. Create a dashboard and publish to PowerBI Service

5. Installing on-premises data gateway

Run the installer and register the gateway

Go back to Power BI Online and go to the [Manage Gateways].

Page 19: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 19 | 40

Select [Add data sources to use the gateway]

II.6 Comparison table

The table below provides with pros and cons of each method with some recommendations

on using it for the different projects

Data source PBI skills Data Protection

Restricted Access to the dataset

Additional Data transformation

DB Size and complexity

Project

Dropbox Basic potential risk: a shareable link which publicly available

potential risk:

a file could be accidentally deleted, too many people have access to it

It required to apply the additional steps to get data in a readable format

Small, not complex

Short-term

Google Drive Basic

OneDrirve Basic

SharePoint Basic

Kobotoolbox Intermediate

the flat table needs to be converted in a proper format

Medium Mid-term

PostgreSQL Advanced

It support

Big, complex Long-term

Page 20: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 20 | 40

III. Preparing an Excel data

III.1. The list of recommendations

The following is a list with the most common changes that need to apply before connecting

data to PowerBI

1. Modify the structure of the table to plain table

Leave at the top name of the columns

Remove merged columns, such as, Acute Malnutrition based on WHO Standards z-

scores (children 6-59 months of age); Stunting based on WHO Standards z-scores

(children 6-59 months of age)

Rename the columns by adding a shorter name

Column Suggestions

Nature of context - protracted >= 3 yrs,

non-protracted < 3 yrs

Rename the column (Ex, "Nature of

context")

Refugee, Not refugee, mixed Rename the column (Ex, "Type of

beneficiaries")

2. For each column add the proper date type (date/text/number)

Column Suggestions

SAM z-score and/or oedema,% Change data format: Number

Remove: text, ‘n.a’ category, sings as %

(move to an additional column if needed)

U5 population in the surveyed area (in red

from popstats)

Change data format: Number

Remove: text, ‘n.a’ category, sings as %

(move to an additional column if needed)

3. Apply data validation rules by adding drop-down list and cascading selection

Column Suggestions

Region Drop-down list

Country Drop-down list (Connection between

Region and Country, Cascading list)

Location Drop-down list (Connection between

Region > Country>Location, Cascading

list)

Month A drop-down list of months and split into

two columns ( start and end period)

Refugee, Not refugee, mixed Drop-down list (Refugee, Not refugee,

mixed, Survey on Older people >60,

Unregistered refugees)

Page 21: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 21 | 40

4. Format your data as a table

5. Due to a large number of headers, split the table into smaller tables for each section,

copy/paste each table to new tabs by linking them together by unique Key field

Note. Please use a meaningful name for each table. It will simplify the process of

connecting data to PowerBI

Page 22: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 22 | 40

III.2. Working on the modified structure of Excel database

List of modules is presented below

- Instructions

- Key_Location_Date

- General Info

- Acute Malnutrition WHO

- Acute Malnutrition NCHS

- MUAC Malnutrition

- Stunting WHO

- Stunting NCHS

- Underweight

- Overweight

- Anaemia childre 6-59

- Anaemia children 6-23

- Anaemia women 15-49

- Mortality_rate

- VA_measle_diarrhoea_BSFP-U5

Page 23: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 23 | 40

- IYCF

- Food secutiry module

- Wash module

- Mosquito net module

- Trend Sheet

- Survey info

- GAM_stunting_anaemia_scenatio

- SOWC

- Secure Info

- Drop-down list (Maintenance tab)

- Location list (Maintenance tab)

III.3. How manually add or update the data

III.3.A. Generate key

1. Go to Key_Location_Date Tab

2. Add a New Key

- Add a new row by expanding the table

- add all the necessary information:

- Region (drop-down list generated based on values from Location list sheet)

- Country (drop-down list generated based on values from Location list sheet)

- Location (drop-down list generated based on values from Location list sheet)

- If other, specify a main location (free text)

- Does the data cover multiple sites? (Yes/No)

- Year (Number field, the value should be greater than 1990)

- End Month (Optional field, drop-down list generated based on values from Drop-down list sheet )

- Type of beneficiaries

If there is a duplication, the keys would be highlighted with red color

Page 24: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 24 | 40

III.3.B. Fill in with data all sheets

1. Add a new row by expanding the table

2. Select a key from the drop-down list and fill in with data

Please add a new row on each sheet for a new key, even if there is no data. Don’t add a

new row without specifying a key

III.3.C. How to modify a Cascading list

Add a new Region

1. Go to Location List sheet

2. Add a new row under Region column [Table name is location_list_table_Region]

3.Enter the name of the new region

Page 25: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 25 | 40

4. Name of Region will automatically appear in a drop-down list

Add a new country

1. Go to Location List sheet

2. Add a new column

3. Go to Formulas > Name manager and click on New Name

Enter a new name and formula by following the template Name=Table[Column]

Table name is location_list_Region_Cascade

Page 26: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 26 | 40

Add a new location

1. Go to Location List sheet and find country table (Table name is

location_list_Country)

2. Add a new column

3. Go to Formulas > Name manager and click on New Name

Enter a new name and formula by following the template Name=Table[Column]

Table name is location_list_Country

III.4. How to import data

III.4.A. Load data from KoboToolbox

1. Log into your Kobotoolbox account

Page 27: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 27 | 40

2. Choose the form and then click on Data >Downloads

3. Select the “export type” is “XLS” and “values and header format” is “Labels”

4. Click on Export and wait until the file is loaded

5. Proceed with loading the data

Page 28: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 28 | 40

III.4.B. Upload data to Excel database

1. Open the database and go to Instructions tab

2. Click on Import Data button

3. Select the file and wait until the data is loaded

The system notifies you if there is any duplication or submission was modified

III.5. How to filter data across the tabs

1. Go to Key_Location_Date tab

Page 29: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 29 | 40

2. Filter the data using headers

3. Click on apply filters and wait until the data are filters across the tabs

4. If you need to reset all the filters, click on the Reset button

IV. Cleaning and transformation of Kobo data

IV.1. List of transformations

The following is a list with the most common transformations that need be applied:

Rename table(s)

Rename fields

Remove unnecessary fields

Page 30: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 30 | 40

Check decimal numbers. Especially check separators defined by system’s regional

settings.

Calculate new field(s)

Page 31: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 31 | 40

Add measure(s)

Create new table(s)

Add relationships between the tables

IV.2. Direct connection to ArgGIS

To avoid a feature limitation (the service returns a maximum of 1000 features), a direct query

for each country was created and then they all were merged in the Global table.

Also, there is a separate additional file that is linked to Global database where we can add

locations that were not found on ArcGIS service.

Here are the steps on how to query data for a specific country (Example. Algeria, code – ALG)

1. Please go to Query Editor> New Source> Blank Query

Page 32: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 32 | 40

2. Copy the query below by replacing the country code

= Table.FromColumns({Lines.FromBinary(Web.Contents("https://gis.unhcr.org/arcgis/rest/services/core/core_prod/MapServer/0/query?where=

iso3%3D%27ALG%27&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&in

SR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=*&returnGeometry=true&returnTrueCurves=false&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&resultOffset=&resultRecordCount=&queryByDistance=&returnExtentsOnly=false&datumTransformation=&parameterValues=&rangeValues=&f=geojson"), null, null, 1252)})

Note. For private service, you will need to add &token=yourGeneratedToken

=

Table.FromColumns({Lines.FromBinary(Web.Contents("https://gis.unhcr.org/arcgis/rest/services/sector/

ph_covid19_view/MapServer/1/query?where=1%3D1&text=&objectIds=&time=&geometry=&geometryT

ype=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=&retu

rnGeometry=true&returnTrueCurves=false&maxAllowableOffset=&geometryPrecision=&outSR=&returnId

sOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&return

Z=false&returnM=false&gdbVersion=&returnDistinctValues=false&resultOffset=&resultRecordCount=&qu

eryByDistance=&returnExtentsOnly=false&datumTransformation=&parameterValues=&rangeValues=&f=

geojson&token=yourGeneratedToken"), null, null, 1252)})

To generate this token you need to go to

https://gis.unhcr.org/arcgis/tokens/generateToken

Page 33: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 33 | 40

3. Transform data to Json format

4. Expand column 1

5. Expand column1.crs

Page 34: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 34 | 40

6. Expand Column1.crs.properties

7. Expand Column.features

8. Expand Column1feature1

Page 35: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 35 | 40

9. Expand Column1.Feature.geometry

8. Extract values for Column1.features.geometry.coordinates

Page 36: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 36 | 40

10. Split column in 2 separate columns

Before splitting the columns, please duplicate this column. To do so, right-click on the column

name, and select Duplicate Column option from the context menu.

Please select the Split Columns and then select By Delimiter option.

Please do not rename the columns to avoid the problems with merging the data to Global

tables

All the previous steps can be replaced by the query below (you need to replace

only country code)

Page 37: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 37 | 40

let

Source = Table.FromColumns({Lines.FromBinary(Web.Contents("https://gis.unhcr.org/arcgis/rest/services/core/core_prod/MapServer/0/query?where=iso3%3D%27DZA%27&text=&objectIds=&time=&geometry=&geom

etryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=*&returnGeometry=true&returnTrueCurves=false&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&resultOffset=&resultRecordCount=&queryByDistance=&returnExtentsOnly=false&datumTransformation=&parameterValues=&rangeValues=&f=geojson"), null, null, 1252)}),

#"Parsed JSON" = Table.TransformColumns(Source,{},Json.Document),

#"Expanded Column1" = Table.ExpandRecordColumn(#"Parsed JSON", "Column1", {"type", "crs", "features"}, {"Column1.type", "Column1.crs", "Column1.features"}),

#"Expanded Column1.crs" = Table.ExpandRecordColumn(#"Expanded Column1", "Column1.crs",

{"type", "properties"}, {"Column1.crs.type", "Column1.crs.properties"}),

#"Expanded Column1.crs.properties" = Table.ExpandRecordColumn(#"Expanded Column1.crs",

"Column1.crs.properties", {"name"}, {"Column1.crs.properties.name"}),

#"Expanded Column1.features" = Table.ExpandListColumn(#"Expanded Column1.crs.properties", "Column1.features"),

#"Expanded Column1.features1" = Table.ExpandRecordColumn(#"Expanded Column1.features", "Column1.features", {"type", "id", "geometry", "properties"}, {"Column1.features.type", "Column1.features.id", "Column1.features.geometry", "Column1.features.properties"}),

#"Expanded Column1.features.geometry" = Table.ExpandRecordColumn(#"Expanded Column1.features1", "Column1.features.geometry", {"type", "coordinates"}, {"Column1.features.geometry.type", "Column1.features.geometry.coordinates"}),

#"Extracted Values" = Table.TransformColumns(#"Expanded Column1.features.geometry",

{"Column1.features.geometry.coordinates", each Text.Combine(List.Transform(_, Text.From), ","), type

text}),

#"Split Column by Delimiter" = Table.SplitColumn(#"Extracted Values", "Column1.features.geometry.coordinates", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Column1.features.geometry.coordinates.1", "Column1.features.geometry.coordinates.2"}),

#"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.features.geometry.coordinates.1", type number}, {"Column1.features.geometry.coordinates.2", type number}}),

#"Expanded Column1.features.properties" = Table.ExpandRecordColumn(#"Changed Type", "Column1.features.properties", {"objectid", "pcode", "iso3", "name", "name_alt", "loc_type", "loc_subtype", "createdate", "createby", "closedate", "updatedate", "updateby", "source", "unhcr_assist", "footnote", "comments", "status", "globalid"}, {"Column1.features.properties.objectid", "Column1.features.properties.pcode", "Column1.features.properties.iso3",

"Column1.features.properties.name", "Column1.features.properties.name_alt",

"Column1.features.properties.loc_type", "Column1.features.properties.loc_subtype", "Column1.features.properties.createdate", "Column1.features.properties.createby", "Column1.features.properties.closedate", "Column1.features.properties.updatedate", "Column1.features.properties.updateby", "Column1.features.properties.source", "Column1.features.properties.unhcr_assist", "Column1.features.properties.footnote", "Column1.features.properties.comments", "Column1.features.properties.status", "Column1.features.properties.globalid"}),

#"Filtered Rows" = Table.SelectRows(#"Expanded Column1.features.properties", each true)

in

#"Filtered Rows"

Page 38: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 38 | 40

V. Publish dashboard from PowerBI desktop to PowerBI service

1. Save the report as a new .pbix file. File > Save As

2. Select File > Publish > Publish to Power BI.

For the first time, you will be asked to sign into your Power BI service account and select

the destination on Power BI service (My workplace).

3. Once the dashboard is published, you will be able to open it in Power BI service by clicking

on the link.

4. In Power Bi service interface, if you directly accessed the Report view, skip points 4 and

otherwise select Workspaces > My Workspace.

5. Then, go to Reports section and click on your file name.

Page 39: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 39 | 40

6. In the Report view, find File > Publish to web

7. Once the dashboard is published to the web, you will be able to see the window with the

link to the dashboard which you can use in your email.

8. To schedule an automatic refresh go to your Dataset, click on the “...” and select Schedule

Refresh.

Page 40: Power BI User Guide - CartONG

Power BI User Guide

[email protected] | www.cartong.org Page 40 | 40

9. Turn to ‘On’, choose the frequency (hourly, daily or weekly depending on the Power BI

version you have) and the time of the refresh. Don’t forget to click Apply at the bottom

to validate everything.