Skip to main content
Announcements
Qlik Cloud maintenance is scheduled for this weekend May 11-12. View maintenance windows per region here.

How to import and export master items using Microsoft Excel with Qlik Application Automation

0% helpful (0/1)
cancel
Showing results for 
Search instead for 
Did you mean: 
Ionut_Dumitrascu

How to import and export master items using Microsoft Excel with Qlik Application Automation

Last Update:

Feb 23, 2023 1:54:12 AM

Updated By:

Sonja_Bauernfeind

Created date:

Apr 29, 2022 8:01:44 AM

Attachments

This article explains how to import and export master items to and from a Qlik Sense app using the Microsoft Excel connector in Qlik Application Automation.

Content:

 

The first part of this article will explain how to export all of your master items configured in your Qlik Sense App to a Microsoft Excel sheet. The second part will explain how to import those master items from the Microsoft Excel sheet back to a Qlik Sense App.

Export master items to a Microsoft Excel sheet

For this, you will need a Qlik Sense app in your tenant that contains measures, dimensions, and variables you want to export. You'll also need an empty Microsoft Excel file. The image below contains a basic example on exporting master items.

Emile_Koslowski_0-1651225954058.png


The following steps will guide you through recreating the above automation:

  1. Add the Create Workbook Session block from the Microsoft Excel connector. Configure it with the following settings:
    1. Drive id -> use do lookup 
    2. Item id -> use do lookup to find the empty destination file, if you don't know the path of your file, you can do an empty search (if it isn't located in a folder)

      Emile_Koslowski_0-1651223685282.png

       

  2. Add the Add Worksheet block from the Microsoft Excel connector. Use the same Drive Id & Item Id from the previous step and configure the Name parameter to a string of your choice. In this example, we'll use Measures.

    Emile_Koslowski_4-1651224933912.png

     

  3. Add the Create Excel Table With Headers block from the Microsoft Excel connector. This block will create a table inside the sheet from the previous step. Specify the following in the block's configuration:
    1. Start Row -> 1
    2. Start Column -> A
    3. End Column -> E
    4. Headers -> Field,Name,Label Expression,Description,Tags,Measure Color, Segment Color, Number Format
    5. Name -> Measures
  4. Add a List Measures block from the Qlik Cloud Services connector and also a Get Measure block inside the loop created by the List Measures block, configure it to get the current item in the loop. Add two variables to convert Gradient and NumFormat JSON objects to string.

    Emile_Koslowski_3-1651224895013.png

     

  5. Add an Add Row To Table block from the Microsoft Excel connector inside the loop after the Get Measure block. This will add every measure's information to the table one by one. Set the Drive Id, Item Id, Worksheet, and Table Id to the corresponding values from the previous blocks.
    The Row parameter should be an array of values for every header we specified in the Create Excel Table With Headers block (and in the same order). Title, Label expression, and Description should be encapsulated in double-quotes. Apply the JSON encode formula to the value for the Definition (qDef) and apply the Implode formula to the value for the Tags. 

    image (2).png

  6. Add a Close Workbook  Session block from the Microsoft Excel connector. Specify the same Drive Id & Item Id as in the previous blocks and configure the Session Id to the Id returned by the Create Workbook Session block.

An export of the above automation can be found at the end of this article as Export master items to a Microsoft Excel sheet.json

Import master items from a Microsoft Excel sheet

For this example, you'll first need a Microsoft Excel file with sheets configured for each master item type (dimensions, measures, and variables). Use the above example to generate this file. The image below contains a basic example on importing master items from Microsoft Excel to a Qlik Sense app.

Emile_Koslowski_1-1651226154572.png

  1. Add the List Rows With Headers block from the Microsoft Excel connector to read master items from the Excel file. Configure the block with the following settings:
    1. Drive Id -> use do lookup
    2. Item Id -> use do lookup to find the empty destination file, if you don't know the path of your file, you can do an empty search (if it isn't located in a folder)
    3. Worksheet Name -> the name of the sheet that contains the measures. Feel free to use do lookup
    4. Start Cell -> the upper-left cell of the measures table, this should include the header row, for example, A1
    5. End Cell -> the bottom right cell of the measures table, for example, E23

      Emile_Koslowski_2-1651226486434.png

  2. Add a Condition block inside the loop created by the List Rows With Headers block. The condition will verify that every measure row has the required information to create a measure (name and expression).

    See the below image for an example:

    Emile_Koslowski_4-1651226590993.png

     

  3. Add the Create Or Update Measure block from the Qlik Cloud Services connector to create or update the measure in the destination app. Map each field from the row in the Excel table to the corresponding input field in the Create Or Update Measure block. Measure Id can be left empty since we're matching measures by Name (Measure Ids can be different across apps). See the below image for an example:

    Emile_Koslowski_5-1651226795501.png

An export of the above automation can be found at the end of this article as Import master items from a Microsoft Excel Sheet.json

Follow the same steps to build automations that import/export dimensions and variables.

Edge cases & next steps

Let's go over some edge cases when exporting information to Microsoft Excel:

  • Fields that start with an equals-sign '=' (for example, some variables' definitions) are treated as Excel functions and can be deemed invalid by the Excel API. You can resolve this by adding a single quote before the input field's mapping in the automation. 

    Emile_Koslowski_0-1651233303701.png

  • Fields that contain newlines (for example measure expressions that contain comments) are invalidated by the Excel API. The solution here is to use the JSON formula to encode the string.

    Emile_Koslowski_1-1651233501057.png

     

Please check the following articles for more information about working with master items in Qlik Application Automation and also uploading data to Microsoft Excel.

Follow the steps provided in this article How to import & export automations to import the automation from the shared JSON file.

The information in this article is provided as-is and to be used at own discretion. Depending on tool(s) used, customization(s), and/or other factors ongoing support on the solution below may not be provided by Qlik Support.

 

Labels (2)
Comments
Greg_Oliven
Partner - Contributor III
Partner - Contributor III

Has anyone ever succeeded with this, but with only some of your measures/dimensions/variables? I can't figure out why it's stopping part way through.

Rodlibar
Contributor II
Contributor II

Hi, I'm receiving this error message. Could you now what's the issue? 

Thanks!

{
"error": "Error calling endpoint \"Microsoft Excel - Create Workbook Session\"",
"endpoint": {
"name": "Create Workbook Session",
"datasource": "Microsoft Excel"
},
"request": {
"url": "https://graph.microsoft.com/v1.0/drives/367516f969ca0d8c/items/Master.xlsx/workbook/createSession",
"method": "POST"
},
"response": {
"status": 400,
"body": {
"code": "invalidRequest",
"message": "ObjectHandle is Invalid",
"innerError": {
"code": "invalidResourceId",
"date": "2024-05-08T23:53:13",
"request-id": "f56eewsx-bfb9-48f8-b62d-9d216e15586a",
"client-request-id": "f56eeaeb-bfc9-48f8-32d-9d216e15586a"
}
}
},
"external error": true
}

Version history
Last update:
‎2023-02-23 01:54 AM
Updated by: