workshop power bi for microsoft dynamics nav€¦ · workshop power bi for microsoft dynamics nav...

23
Workshop Power BI for Microsoft Dynamics NAV Julian Wissel Hans Fousert

Upload: others

Post on 29-May-2020

32 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 1

Workshop

Power BI

for

Microsoft Dynamics NAV

Julian Wissel Hans Fousert

Page 2: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 2

Exercise 01 – Customer Item Statistics

What you will do?

In this exercise you will create a customer item sales analyses for Power BI to get familiar with some

of the basics of Power BI for Microsoft Dynamics NAV

The end result may look like this:

What you will use?

To complete this exercise you will work with the following:

- Query object in Microsoft Dynamics NAV

o To create the data set required for the analysis

- Web service in Microsoft Dynamics NAV

o To publish the pages and the query for the analysis as a web service

- Power Query in Excel 2013

o To retrieve the data from the Odata webservice

o To optimize the data for the analyse

o To load the data into Power Pivot

- Power Pivot in Excel 2013

o To create a dataset to be used in the analyses

- Pivot table in Excel 2013

o To create a visualization like the one above – or other ones

This exercise requires that you are familiar with Object Designer in Microsoft Dynamics NAV 2015,

working in Microsoft Dynamics NAV 2015 client in general, and working in Excel 2013 in general.

Page 3: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 3

Step 1 - Preparing the web services in Microsoft Dynamics NAV

You will use the data from 4 different tables:

- Customer master data You will use the Customer Card or List (Page 21 or 22);

- Item master data You will use the Item Card or List (Page 30 or 31);

- Sales data You will combine data from the Value entry + Item ledger

Entry tables in a Query to retrieve the data of sales invoices

and sales credit memos

Exercise 1.1 - Creating the Query object

- Use the Object Designer to create a new Query Object

- Use the Tables and Fields from the screen shot below. Feel free to change the Name

property so that it describes the purpose of the column in the Sales Analyses.

- DataItem Value Entry Filter on Document type: Sales Invoice|Sales Credit Memo

- DataItem Item Ledger Entry DataItemLink Entry No = Value Entry.Item Ledger Entry

Page 4: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 4

Exercise 1.2 - Creating the Web services

- Use Dynamics NAV to insert 3 web services for the following objects

o Page 21 or 22 Customer Card or List Customer master data

o Page 30 or 31 Item Card or List Item master data

o The Query object from the previous step Customer Item Sales

Feel free to change the Service Name column so that it describes the purpose of the data.

Step 2 - Use Power Query to connect to the OData web services

You will need the 3 Odata URLs from the previous step, so we recommend keep that page

open. Thus you can copy and paste the URLs easily.

Exercise 2.1 - Connect to OData web services

- Start Excel to create a new workbook.

- Select the Power Query ribbon and use Get External Data to connect to an OData Feed.

- Connect to the all 3 OData URLs from your NAV web services. The first time you use this

OData URL you may need to define the access credentials. Please use your Windows account.

Exercise 2.2 – Select the columns required for the statistics

- Make sure you have the Power Query window open. In case you haven’t: select Launch

Editor in the Power Query ribbon.

- Select each query to define which columns you want:

o Customers No., Name

o Items No., Description

The easiest way to do this, is to select these columns and apply ‘Remove Other Columns’.

- In the Power Query window select ‘Close and Load To’ in the upper left corner for each of the

3 queries. Activate ‘Only Create Connection’ and ‘Add this data to the Data Model’

Page 5: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 5

Step 3 - Use Power Pivot to define a Data model

Exercise 3.1 - Using Power Pivot

- Close the Power Query window if you’ve still got this open

- In Excel select the Power Pivot ribbon to activate Management.

- In the Power Pivot window, you will find the 3 Power Query connections there as separate sheets.

- Select the Home ribbon -> Diagram View

- Use your mouse to drag a connection between o Customer Item Sales, Item No and Item, No. o Customer Item Sales, Customer No and Customer, No.

Step 4 – Create a Pivot Table for your Customer item statistics

Exercise 4.1 – Defining the presentation in Excel

- Pivot tables and charts can be created from the Power Pivot window. Select the Home

Ribbon, Pivot Table to create an Excel pivot table.

- You will be back in Excel and work with a Pivot Table like you’d normally do.

- Use the columns from Customer, Item and Sales to define the setup of Rows, Columns and

Values in your Pivot table.

- Don’t forget to add Slicers so that you can filter the data in your sales analysis.

Finished!

You’re finished now with this exercise. Save your Excel workbook please and continue with the next

exercise.

Page 6: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 6

Exercise 02 - Applying Parameters in Power Query

What you will do?

You will use the analysis from the previous exercise. You will replace the OData URL in the Power

Query queries with parameters for the OData path and the NAV company. Additionally you will

define parameters for a date filter to retrieve the sales of a specific period.

What you will use?

To complete this exercise you will work with the following:

- The Excel workbook from the previous exercise

- A Excel table in a worksheet

o To enter the required parameter values

- Power Query in Excel 2013

o To define a function to retrieve the parameter values

o To modify the OData connection in the 3 queries

o To modify the Sales query to apply the date filter

Step 1 - Use Customer Item Statistics workbook

Exercise 1.1 - Make a copy

- Save this workbook with a different name. Thus you have a backup of the previous exercise.

Step 2 - Defining the Parameters and their values

Exercise 2.1 – An Excel table with the parameters

- Enter the following parameters in Excel – preferably a new worksheet. Please check the

values of your OData path, the company name you are using in NAV and of course the

period:

Page 7: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 7

- Select all the cells you just entered. Next, select the Excel ribbon to Insert Table.

- Change the Table Name of your table so that it is a more logical name:

Step 3 - Adjust the queries in Power Query

Exercise 3.1 - Create a Power Query function

- Use the Power Query ribbon to select From Other sources, Blank Query

- The Power Query window will open. Select Advanced Editor in the Home ribbon

- Enter the following code (or copy and paste it from the PDF file we provided).

BEWARE:

o the code is case sensitive;

o Use the correct Excel Table Name and Column names. Our codes refers to the names

used in the picture above.

(ParameterName as text) => let

ParamSource = Excel.CurrentWorkbook(){[Name="Parameters"]}[Content],

ParamRow = Table.SelectRows(ParamSource, each ([Parameter] = ParameterName)),

Value = if Table.IsEmpty(ParamRow) = true

then null

else Record.Field(ParamRow{0},"Value")

in

Value

- Once you’re done with the code, enter a logical name for the function in the Query Settings.

E.g.

Page 8: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 8

Exercise 3.2 - Modify the OData connection in 3 queries

- Select the Customers query and open the Advanced editor

- The query has a row starting with ‘Source= …’. There you will recognize the OData URL.

- Replace the first 2 lines of the query with the following code:

let

Odata_Basepath = fnGetParameter ("Odata Basepath"),

Company = fnGetParameter ("Company"),

Source = OData.Feed(Odata_Basepath & "/Company('" & Company & "')/Customers",

- Repeat this for the Items and the Sales Invoiced queries. Be aware of the last part of the

Source-statement though!

Exercise 3.3 - Add a date filter to the Sales query

- Select the Customers query and open the Advanced editor

- Add 2 functions before the Source-statement to read the values of the Date parameters:

FromDate = Date.ToText (DateTime.Date(fnGetParameter ("From date")), "yyyy-MM-dd"),

ToDate = Date.ToText (DateTime.Date(fnGetParameter ("To date")), "yyyy-MM-dd"),

- Add a filter to the Source-statement:

Source = OData.Feed(…/Sales Invoiced?$filter=Invoiced_At ge datetime'"&FromDate&"'

and Invoiced_At le datetime'"&ToDate&"'")

- Close the Power Query window.

Exercise 3.4 - Testing the queries

- Select the Data ribbon in Excel to refresh all data. Do you get the correct sales data?

- Change the date filter values and refresh the data again to see this working.

Additional exercise 3.5 - Parameters for the web services

- The web service names are still hard coded. Do you think you could replace these with

parameters like the OData path and Company name?

Finished!

You’re finished now with this exercise. Save your Excel workbook please and continue with the next

exercise.

Page 9: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 9

Exercise 03 - Many to many relationship in Power BI

What you will do?

In this exercise you will create a Power BI report based on the item sales report of the previous

example. You will see the different development environments of Power BI Desktop and Excel. The

data model includes one challenge: a many-to-many-relationship between the customer/contact

table and the contact industry group. You will create power bi visualizations and publish the report to

PowerBI.com. The result will look like the following:

What will you use?

To complete this exercise, you will work with the following:

- Query objects in Microsoft Dynamics NAV

o Create new queries and re-use the existing query from previous exercise

- Web Services in Microsoft Dynamics NAV

o To add new endpoints plus re-use endpoints from previous exercise

- Define Queries in Power BI Desktop

o To retrieve the data from the OData web services

o To optimize the data for the analysis

o To load the data into the data model

Page 10: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 10

- Define Data model in Power BI Desktop

o To create relationships, measures and data categories

- Create visualizations in Power BI Desktop

- Use www.PowerBI.com

o To upload and to interact with the report on the Internet and apps

Step 1 - Creating the NAV objects

Hint: You may import the object-files CRMSalesQueries.fob or CRMSalesQueries.txt that we

provided if you directly want to focus on the Power BI part. If so, go to step 2 after importing

(and compiling) the objects.

Exercise 1.1 - Creating the NAV Query object Contact Industry Groups

- Create a new Query object in Dynamics NAV that joins the contact no. from the contact table

with the contact industry group table. This table will be used to link contacts to industry

groups.

- Use the DataItemLinkType “Exclude Row If No Match” since we are only interested in

contacts that are assigned to any industry group

- Compile and save the query.

Page 11: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 11

Exercise 1.2 - Creating the NAV Query object Customers CRM

- Create a second Query object in Dynamics NAV in order to extend the contact information

(contact no.) to the customer table. Alternatively the customer page could be extended by

using some C/AL, using a query objects however does not require any C/AL which is why we

recommend it

- Add the following fields from the customer table

o No (Customer_No)

o Name (Customer_Name)

o Address (Customer_Address)

o City (Customer_City)

o Salesperson Code (Salesperson_Code)

o Post Code (Customer_Post_Code)

o Country/Region Code (Customer_Country_Code)

- Add the Contact Business Relation table to retrieve the contact no. of a customer

- Add the Contact Table

o No. (Contact_No)

- Data item Contact Business Relation should have the following link:

Page 12: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 12

- Data item Contact should have the following link:

- Compile and save the query.

If anything did not work here, please use the Dynamics NAV objects that we provided.

Step 2 - Publishing the NAV queries as OData web services

Exercise 2.1 - Use Dynamics NAV Client to create web services

- Publish web services for the following Page and Query objects

o the 2 Query objects that you created in the previous step 1;

o Page 31 (Item List)

o Query 51000 (as created in Exercise 1 or found in CRMSalesQueries.fob)

- Make sure that the objects were published with the following names:

Page 13: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 13

Exercise 2.2 - Set up Services Default Company

- If your database has multiple companies, make sure that a Services Default Company is set in

the Dynamics NAV Server configuration (Restart the service if a change was necessary):

- Also make sure that OData Services are enable (OData-tab)

Step 3 - Power BI Desktop – Reading the OData Web Services

Exercise 3.1 - Get the data from the 4 OData Web Services

- Start Power BI Desktop

- Open from the Ribbon (Home-Tab) Get Data – Odata Feed

- Enter the base URL of your OData feeds (e.g. http://SERVER:7718/DynamicsNAV80/OData/)

You can copy this from the web services. just make sure to remove the part after OData/

- Select authentication method (Basic for powerbi.com), populate user name and password or

use Windows Authentication

- Select those web service endpoints that you published in the previous step:

Page 14: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 14

Exercise 3.2 - Transform the data: improve readability of data model

- Click Edit in the import-wizard or Edit Queries on the Home tab

- Remove unnecessary fields on item table

o Select item table - mark the first two columns (No, Description) and right click

“Remove other columns”

o Change the names of the column No to Item No and Description to Item Description

- Change the query names to obtain more user-friendly names

o Right click on Query – properties

o E.g. change ContactIndustryGroup to Contact Industry Group

o Change CustomersCRM to Customers etc.

- Bonus exercise: remove underscores of all field names of the customer table to improve

readability of the data model; you may use our function as explained here

http://navida.eu/nav-underscores to automatically replace all underscores

Exercise 3.3 - Transform the data: change data types

- Change the data types of all numeric columns and dates of the customer item sales table:

o On the Customer Item Sales table select the columns Invoiced quantity, Sales

Amount, Cost Amount Direct and Discount Amount

o Click Detect Data Type on the Transform tab

Exercise 3.4 - Transform the data: replace blank country codes for geographical reporting

- On The Customer table right click the customer country code - Replace values. Leave the field

Value to find empty (to find empty country codes) and enter the value of the local ISO

country code for “Replace With”.

- Bonus exercise: Replace this value based on another query that retrieves the local country

code from a separate Odata-feed (Page Company information) or as an additional field of the

customer table.

- The simple (hard coded) solution would look like this for Germany:

Page 15: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 15

Exercise 3.5 - Transform the data: create an unambiguous city column for Bing maps

- On the Customers table, rename the Customer City column to Customer City Raw (Right Click

Rename or just double-click the column header)

- Select the Customer City Raw and the Customer Country Code fields (hold CTRL-Key while

clicking) and click on Merge Columns in the Add Column tab (not on the Transform tab)

- Choose a name for the new column and a separator (e.g. – Custom – “, ”). This field will be

used to help Bing maps to find the right location.

- Close the Edit queries window. Use File, Save as to save your work.

Step 4 - Power BI Desktop – Create the data model

Exercise 4.1 - Create relationships

- In the manage relationship view, make sure that the following relationships are set up

(Power BI will try to create relationships automatically based on column names and actual

data):

Page 16: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 16

- Check in the advanced

options of all relationships

(except Item No relationship)

that Cross Filter direction is

set to Both.

This is necessary to handle

many-to-many relationships

(in our example customers to

industry groups):

Exercise 4.2 - Hide internal/technical fields and change data category

- In the report view on the customer table hide the column customer city raw (Right click –

Hide in Report View)

- Navigate to the data tab - table customer, click the column Customer City and change the

data category (tab Modeling) to City:

- Change the data category of Customer Country to Country/Region

Step 5 - Power BI Desktop - Create the visualizations

- Add a bar chart, a treemap, a map and a table to your report page

Page 17: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 17

The bar chart: The map:

Page 18: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 18

- The result in a German Cronus database looks like:

- Save you work to continue working on in the next exercise.

The tree map: The table:

Page 19: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 19

BONUS Exercise - Bring the report to the Cloud

What you will do?

The results of Exercise 3 (creating a many to many analysis in Power BI Desktop) will be

published on www.powerbi.com.

To be able to do this you need an account for this website. We recommend to skip this

exercise if you don’t have any to save you time during this workshop.

Exercise

- Open your file in Power BI Desktop

- Publish the result to www.powerbi.com:

- In www.powerbi.com select your charts and select which one(s) to pin to a dashboard:

- Use Q&A functionality in dashboard. For example type “Show sales by city as map”. Add

the result to your dashboard.

Page 20: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 20

Exercise 04 - Cross-company reporting

What you will do?

In this exercise you will extend the previous exercise to enable cross-company reporting. You

will use Power Query functions provided by us that allow returning any table across all

companies. The solution assumes that the master data (customers, items) are harmonized

across companies.

What will you use?

To complete this exercise, you will work with the following:

- Dynamics NAV

o To add another company

- Continue with the result of the previous exercise

o alternatively please use our file CRM Sales.pbix and import the file

CRMSalesQueries.FOB in Dynamics NAV.

- Power BI

o To create functions for cross-company calls

o To use these functions for the single-company fact table

Prerequisites

If you skipped Exercise 3, please read this!

Make sure that a Services Default Company is set in the Dynamics NAV Server configuration

(Restart the service if a change was necessary):

Page 21: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 21

Step 1 - Create a second company in Dynamics NAV

- In Dynamics NAV Windows Client open the Companies page (Departments/Administration/IT

Administration/General/Companies) and use the Copy-Action to create a second company

(choose any name).

- If you are using our FOB (and PBIX-File), please make sure that the following web services are

published:

Step 2 - Power BI Desktop

Open the PBIX-File from the last exercise (CRM Sales) or use the file CRM Sales.pbix that we

provided (if you use the file that we provided, you must import our FOB as well and use our

objects as web services).

Exercise 2.1 - Create a function to retrieve records from any table from any company

- Open the Edit Queries Window

- Click New Source – Blank Query

- Go to the advanced editor (Home – Advanced Editor)

- Replace the existing source code with (copy & paste from our PDF-file):

Let

RecordsPerCompanyFct = (CompanyName,TableName) => let

Source = OData.Feed("YourODataBasePath"),

SelectCompany = Source{[Name="Company",Signature="table"]}[Data],

FilteredRows = Table.SelectRows(SelectCompany, each ([Name] =

CompanyName)),

UnpivotedOtherColumns = Table.UnpivotOtherColumns(FilteredRows, {"Name"},

"Attribute", "Value"),

TargetTable =

UnpivotedOtherColumns{[Name=CompanyName,Attribute=TableName]}[Value],

TargetTableWithCompanyName = Table.AddColumn(TargetTable,"Company

Name",each CompanyName)

in

TargetTableWithCompanyName

in

RecordsPerCompanyFct

Page 22: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 22

- Replace the YourODataBasePath-placeholder with your OData-Base Path (e.g.

http://NAVIDA-SERVER:7718/DynamicsNAV80/OData/)

- Finish the Advanced Editor with Done

- Change the name of the new function (Query Settings) to RecordsPerCompany

Exercise 2.2 - Create a function to add Company Name as a column to the tables

- Open the Edit Queries Window

- Click New Source – Blank Query

- Go to the Advanced Editor (Home – Advanced Editor)

- Replace the existing source code with (copy & paste from our PDF-file):

let QueryForAllCompanies = (TableName) =>

let

Source = OData.Feed("YourODataBasePath"),

Company_table = Source{[Name="Company",Signature="table"]}[Data],

Combined =

Table.Combine(List.Transform(Table.Column(Company_table,"Name"),each

RecordsPerCompany(_,TableName)))

in

Combined

in

QueryForAllCompanies

- Replace the YourODataBasePath-placeholder with the Base Path (e.g. http://NAVIDA-

SERVER:7718/DynamicsNAV80/OData/)

- Finish the Advanced Editor with Done

- Change the name of the new function (Query Settings) to RecordsForAllCompanies

- You may read about the inner workings of both functions at http://navida.eu/pbi-cross-

company

Exercise 2.3 - Use RecordsForAllCompanies as the source of the Customer Item Sales table

- Navigate to the Advanced Editor of the Customer Item Sales Query

- Replace the first two lines with this single line (the name depends on the web service name

of the Customer Item Sales Query)

Page 23: Workshop Power BI for Microsoft Dynamics NAV€¦ · Workshop Power BI for Microsoft Dynamics NAV Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g

Workshop Power BI for Microsoft Dynamics NAV

Provided by navida informationssysteme, Germany and Mprise, The Netherlands P a g e | 23

Old:

New:

Bonus Exercise

Define one single query that contains the OData-base path and reference that query instead

of hard-coding the base query into each function.

Step 3 – Company name in Visualizations

Add the field Company Name of table Customer Item Sales as a slicer or treemap.