Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update read me for cloud refreshes #16

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Version History

## 2.0.1 / 2024-11-26

- Update README.md

## 2.0.0 / 2023-10-18

- Migrating to use VS Code Power Query SDK
Expand All @@ -17,7 +21,7 @@

## 1.2.0 / 2022-01-27

- Updated for AVEVA Data Hub
- Updated for CONNECT data services
- Updated dependencies

## 1.1.1 / 2021-11-25
Expand Down
36 changes: 30 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# ADH Power Query M Data Retrieval Sample
# CONNECT data services Power Query M Data Retrieval Sample

**Version:** 2.0.0
**Version:** 2.0.1

Built with [Power Query SDK](https://marketplace.visualstudio.com/items?itemName=PowerQuery.vscode-powerquery-sdk) in [Visual Studio Code](https://code.visualstudio.com/)


The sample code in this repository demonstrates how to connect to ADH and pull data from Streams, Assets, and Data Views using Power Query M. Power Query works with a variety of Microsoft products such as Analysis Services, Excel, and Power BI workbooks. For more information on Power Query M please refer to [Microsoft's documentation](https://docs.microsoft.com/en-us/powerquery-m/).
The sample code in this repository demonstrates how to connect to CONNECT data services and pull data from Streams, Assets, and Data Views using Power Query M. Power Query works with a variety of Microsoft products such as Analysis Services, Excel, and Power BI workbooks. For more information on Power Query M please refer to [Microsoft's documentation](https://docs.microsoft.com/en-us/powerquery-m/).

## Requirements

- [Power BI Desktop](https://powerbi.microsoft.com/en-us/desktop/)
- Register a [Client-Credentials Client](https://datahub.connect.aveva.com/clients) in your AVEVA Data Hub tenant and create a client secret to use in the configuration of this sample. ([Video Walkthrough](https://www.youtube.com/watch?v=JPWy0ZX9niU))
- Register a [Client-Credentials Client](https://datahub.connect.aveva.com/clients) in your CONNECT data services tenant and create a client secret to use in the configuration of this sample. ([Video Walkthrough](https://www.youtube.com/watch?v=JPWy0ZX9niU))
- __NOTE__: This sample only requires read access to resources (Streams, Assets, etc.) to run successfully
- It is strongly advised to not elevate the permissions of a client beyond what is necessary.

Expand All @@ -31,6 +31,30 @@ The sample code in this repository demonstrates how to connect to ADH and pull d

Note: It is not recommended to hard code the app settings directly in the power query scripts as this could pose a security risk.

### PowerBI Service Refreshes

If you plan to publish your PowerBI dashboard to the cloud PowerBI service, you may run into an issue where you cannot refresh your Semantic Model and you'll see the error message **"This dataset includes a dynamic data source. Since dynamic data sources aren't refreshed in the Power BI service, this dataset won't be refreshed."** The problem is that when a published dataset is refreshed, Power BI does some static analysis on the code to determine what the data sources for the dataset are and whether the supplied credentials are correct. Unfortunately in some cases, such as when the definition of a data source depends on the parameters from a custom M function, that static analysis fails and therefore the dataset does not refresh. To determine whether your dynamic data source can be refreshed, open the Data source settings dialog in Power Query Editor, and then select Data sources in current file. In the window that appears, look for the warning message, **"Some data sources may not be listed because of hand-authored queries."** In order to work around this issue, you can edit the sample code to replace any usage of the **"resource"** variable within **Web.Contents()** with your data services resource url.

**For example:**
```C#
GetJson =
try
Web.Contents(
"https://euno.datahub.connect.aveva.com/",
[
RelativePath = authUrl,
Headers = [
#"Content-Type" = "application/x-www-form-urlencoded;charset=UTF-8",
Accept = "application/json"
],
IsRetry = true,
Content = authPOSTBodyBinary
]
),
```

When configuring your scheduled refresh, you should turn on the **“Skip Test Connection”** option on the data source in the Power BI Service and the dataset will refresh even if the call to the CONNECT resource on its own, without the dynamically added client credentials, would result in an error.

## Setting up Excel

1. Open Excel
Expand Down Expand Up @@ -114,7 +138,7 @@ At this point, the data should be consumable in a Power BI Dashboard or Excel Wo
| GetCommunityStreamWindowData.pqm | Returns a collection of stored values from a Community Stream based on request parameters. |
| GetDataViewInterpolatedData.pqm | Returns interpolated data for the provided Data View and index parameters. |
| GetDataViewStoredData.pqm | Returns stored data for the provided Data View and index parameters. |
| GetGraphQLQuery.pqm | Submit a GraphQL query to AVEVA Data Hub. |
| GetGraphQLQuery.pqm | Submit a GraphQL query to CONNECT data services. |

## Running Tests

Expand All @@ -127,5 +151,5 @@ At this point, the data should be consumable in a Power BI Dashboard or Excel Wo

---

For the main ADH samples page [ReadMe](https://github.com/osisoft/OSI-Samples-OCS)
For the main CONNECT data services samples page [ReadMe](https://github.com/osisoft/OSI-Samples-OCS)
For the main AVEVA samples page [ReadMe](https://github.com/osisoft/OSI-Samples)