# Using Sesame Data with PowerBi

1. We will begin by fetching the URL from Sesame. In your Sesame Data Experience, navigate to ‘Endpoints’ and then the endpoint you would like to fetch data from. Here we will be using the `Holdings` endpoint. Select ‘Try it’. Choose the ‘entity’ you will be fetching data for. If you need to filter for Look through results, select ‘Look through’.  Finally, copy the base URL.

<figure><img src="/files/aRfOohCq7mMcLijAUL1N" alt=""><figcaption></figcaption></figure>

2. After opening the PowerBi desktop application, click on ‘Get data’ and then select ‘Web’&#x20;

<figure><img src="/files/ppfys5cOeVFs1oUBwIKb" alt=""><figcaption></figcaption></figure>

3. Paste the Sesame Data URL from (1) and then click ‘OK’

<figure><img src="/files/dqmjGHMevAAP5xIqrYpJ" alt=""><figcaption></figcaption></figure>

4. When the authorization window pops up, select ‘Basic’, type in your Username and Password. You will get these from the ‘API Tokens’ menu in Sesame - [read more about this here](https://docs.landytech.com/authentication/how-to-authenticate). If you see a section allowing you to 'Select which level to apply these settings to', you can leave it as the default (<https://data.api.landytech.net/>).

<figure><img src="/files/G6gPgbRFABnZLHbWRcIn" alt=""><figcaption></figcaption></figure>

Note: If you have already configured an API source from your PowerBi application, these details will be retained by the application. If you want to update them later, you can navigate to ‘File’ > ‘Options and settings’ > ‘Data source settings’.

After adding your username and password, select ‘Save’ or 'Connect'.

5. PowerBi will arrive at a screen similar as below.&#x20;

Before continuing, delete the ‘Applied Steps’ other than ‘Source’:

<figure><img src="/files/cphGooFPOruUuQSBJYbK" alt=""><figcaption></figcaption></figure>

Afterwards, you will see this table, with only 'Source' remaining as an applied step:

<figure><img src="/files/1EGZV4gcHW5sJmqZDIQg" alt=""><figcaption></figcaption></figure>

6. Next, right-click in the cell next to ‘totalPages’ and then select ‘Add as New Query’:

<figure><img src="/files/wo8bDx1HZNJzXJKTm47U" alt=""><figcaption></figcaption></figure>

7. Next, click on ‘Advanced Editor’ at the top:

<figure><img src="/files/Lx91cCQQz112EhPxegkq" alt=""><figcaption></figcaption></figure>

8. Then change the query to produce a list of pages by replacing line 3 by in this text:

&#x20;`totalPages1 = {0..Source[totalPages] -1}`

<figure><img src="/files/thrCiISMgHrKHGFFB6cY" alt=""><figcaption></figcaption></figure>

then click ‘Done’.

9. Right click on ‘List’ and then select  ‘To Table’:

<figure><img src="/files/fHA2LBbYOYlg1IVMcm9F" alt=""><figcaption></figcaption></figure>

Click ‘OK’ on the popup.

10. Select the original table and click on ‘List’. This will open a new table (or *list*):

<figure><img src="/files/ZoGr9YvxB4PlG7VSRIlo" alt=""><figcaption></figcaption></figure>

11. Then right-click on ‘List’ and then select the ‘To Table’ option and click ‘OK’ on the popup:&#x20;

<figure><img src="/files/uqEdKVoEeZ5uiI9jjAbG" alt=""><figcaption></figcaption></figure>

12. Click on Expand Columns icon:

<figure><img src="/files/ju42FLsv4qgeJD8pytVk" alt=""><figcaption></figcaption></figure>

13. Deselect ‘*Use original column value as pre-fix*’, and click ‘Load more’

<figure><img src="/files/vKh5irjchH1SGgJv0Eag" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/eVbFG2lqLoPBYDR0DfmI" alt=""><figcaption></figcaption></figure>

Select OK

14. Next, click on ‘Advanced Editor’ (in the ‘Home’ tab)&#x20;

<figure><img src="/files/GRZ5Ck1ikdzLY0cPQQ6Z" alt=""><figcaption></figcaption></figure>

15. Add the following code as the first line:\
    `(page as text) =>`

And, in the ‘Source’ line, after the entityId, remove the closing quote, and replace it with:

`?pageNumber="&page`

<figure><img src="/files/IQc19X3Y9BvRSnlky0Yl" alt=""><figcaption></figcaption></figure>

The click ‘Done’

16. To ease readability, rename the function to getPages

Do this by right-clicking, ‘Rename’ on the item itself

<figure><img src="/files/beW70l0a1wv2kLAOmqSe" alt=""><figcaption></figcaption></figure>

17. Navigate back to your table in the left hand navigation, then on ‘ABC/123’ icon, select ‘Text’ to change the column type to Text:

<figure><img src="/files/GfSiNOFb6u0JjneWIe3R" alt=""><figcaption></figcaption></figure>

18. In the ‘Add Column’ tab, select ‘Invoke Custom Function’:

<figure><img src="/files/1GXD2V0D79UkXXHoCXkA" alt=""><figcaption></figcaption></figure>

&#x20;

19. Select the function (‘getPages’) you created previously.

If not already selected, under ‘Page’, select ‘Column Name’. Then select Column1 from the right hand menu.&#x20;

<figure><img src="/files/6fuyZGWorghlb5HpEJoH" alt=""><figcaption></figcaption></figure>

Finally, click ‘OK’

PowerBi will now begin fetching your data from Sesame. If there are many records, and therefore many pages, this will take a bit of time.

20. When the data fetching is complete, click ‘Expand Columns’:

<figure><img src="/files/oWuC1uiC3qgO2WkEUBt6" alt=""><figcaption></figcaption></figure>

21. Select ‘Load more’ before selecting ‘OK’

&#x20;

<figure><img src="/files/i1qzFZAgnr7aZ3NJ8Oee" alt=""><figcaption></figcaption></figure>

22. Now, you can rename any columns that are being imported, or remove any if required. You will observe that each column appears twice. Please ensure that you rename or remove both values if choosing to do so.

<figure><img src="/files/Ndrof4crQ2BduK2Xg66s" alt=""><figcaption></figcaption></figure>

As ‘accountCode’ is a legacy field, and so we can remove it if desired, as seen below.

<figure><img src="/files/nQQJMViiQmRIIoyiirHB" alt=""><figcaption></figcaption></figure>

23. Finally, click Close & Apply:

<figure><img src="/files/RKeCJLkyLdKWKTyifAYB" alt=""><figcaption></figcaption></figure>

After a few seconds, you will observe the below as PowerBi imports your data from Sesame Data.

<figure><img src="/files/FqX9QuzoueQbfUgrIBZs" alt=""><figcaption></figcaption></figure>

Once loading is complete, you will see this screen, with your table and columns as below:

<figure><img src="/files/MNoHZHiGdpb9FQP8Tc1G" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.landytech.com/tutorials-recipes/using-sesame-data-with-powerbi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
