| Title: | PowerBI Connectivity |
|---|---|
| Description: | Defines functions needed to connect to PowerBI dataflows/datasets. |
| Authors: | Healthcare Quality Intelligence Unit (Western Australia Health) [aut, cre] |
| Maintainer: | Healthcare Quality Intelligence Unit (Western Australia Health) <[email protected]> |
| License: | GPL (>= 3) + file LICENSE |
| Version: | 0.0.12 |
| Built: | 2026-05-28 02:41:04 UTC |
| Source: | https://github.com/AUS-DOH-Safety-and-Quality/qiverse |
A collection of R functions for working with PowerBI Dataflows and Datasets
Maintainer: Healthcare Quality Intelligence Unit (Western Australia Health) [email protected]
Useful links:
https://github.com/AUS-DOH-Safety-and-Quality/qiverse/qiverse.powerbi
Report bugs at https://github.com/AUS-DOH-Safety-and-Quality/qiverse/issues
For more efficient storage, PowerBI will store strings in a compressed binary format - compressed using the deflate algorithm and then represented as a base64 string.
This function takes the base64 string and decompresses it to return the original string.
decompress_string(compressed_string)decompress_string(compressed_string)
compressed_string |
The base64 string of the compressed data. |
Original string after decompression.
table_str <- "i45W8lXSUfJNzElVitWJVnIDctxSc2HcCCDXMS+/JCO1SKEktSgXLBgKFAzNy87LL88D8/2AfL/8EoXigtTkzLTM1BSl2FgA" decompress_string(table_str) |> cat() # [["M","Male"],["F","Female"],["X","Another term"],["U","Unknown"],["N","Not specified"]]table_str <- "i45W8lXSUfJNzElVitWJVnIDctxSc2HcCCDXMS+/JCO1SKEktSgXLBgKFAzNy87LL88D8/2AfL/8EoXigtTkzLTM1BSl2FgA" decompress_string(table_str) |> cat() # [["M","Male"],["F","Female"],["X","Another term"],["U","Unknown"],["N","Not specified"]]
This function provides the ability to download tables from within PowerBI dataflow themselves, rather than requiring that they first be exposed via a PowerBI dataset.
download_dataflow_table( workspace_name, dataflow_name, table_name, access_token, verbose = TRUE )download_dataflow_table( workspace_name, dataflow_name, table_name, access_token, verbose = TRUE )
workspace_name |
The PowerBI workspace name. |
dataflow_name |
The name of the PowerBI Dataflow within the workspace. |
table_name |
The name of the table within the PowerBI Dataflow to be accessed. |
access_token |
The token generated with the correct PowerBI Dataflow permissions. Use get_az_tk('pbi_df') to create this token. |
verbose |
Whether to print status messages while the function is running. Default is TRUE. |
A data.frame of the PowerBI table from the PowerBI dataflow.
## Not run: # Create PowerBI Dataflow azure token tk <- get_az_tk('pbi_df') # Load AD dummy file from PowerBI dataflow ad_dummy <- download_dataflow_table( workspace_name = "My Workspace Name", dataflow_name = "My Dataflow Name", table_name = "My Table Name", access_token = tk$credentials$access_token ) ## End(Not run)## Not run: # Create PowerBI Dataflow azure token tk <- get_az_tk('pbi_df') # Load AD dummy file from PowerBI dataflow ad_dummy <- download_dataflow_table( workspace_name = "My Workspace Name", dataflow_name = "My Dataflow Name", table_name = "My Table Name", access_token = tk$credentials$access_token ) ## End(Not run)
execute_xmla_query()
and execute_rest_query() functions.Download a specified dataset table into R using either the XMLA or REST API
endpoints. This is a convenience wrapper around the execute_xmla_query()
and execute_rest_query() functions.
download_dataset_table( workspace, dataset, table, method = "XMLA", access_token )download_dataset_table( workspace, dataset, table, method = "XMLA", access_token )
workspace |
Name of the workspace containing dataflow |
dataset |
Name of the dataset containing table |
table |
Name of the table to download |
method |
The API to use for downloading the table. Valid values are "XMLA" (the default) and "REST" |
access_token |
The token generated with the correct PowerBI Dataset permissions. Use get_az_tk('pbi_ds') to create this token. |
DataFrame containing downloaded table
Execute a DAX query against a specified PowerBI Dataset using the REST API endpoint.
execute_rest_query(workspace, dataset, query, access_token)execute_rest_query(workspace, dataset, query, access_token)
workspace |
Name of the workspace containing dataflow |
dataset |
Name of the dataset to execute query against |
query |
DAX query to execute |
access_token |
The token generated with the correct PowerBI Dataset permissions. Use get_az_tk('pbi_ds') to create this token. |
DataFrame containing results of query
Execute a DAX query against a specified PowerBI Dataset using the XMLA API endpoint.
execute_xmla_query(workspace, dataset, query, access_token)execute_xmla_query(workspace, dataset, query, access_token)
workspace |
Name of the workspace containing dataflow |
dataset |
Name of the dataset to execute query against |
query |
DAX query to execute |
access_token |
The token generated with the correct PowerBI Dataset permissions. Use get_az_tk('pbi_df') or get_az_tk('pbi_df') to create this token. |
DataFrame containing results of query
Request metadata for all dataflows in specified workspace
list_dataflows(workspace, access_token)list_dataflows(workspace, access_token)
workspace |
Name of the workspace containing dataflows |
access_token |
The token generated with the correct PowerBI Dataflow permissions. Use get_az_tk('pbi_df') to create this token. |
DataFrame containing the names, GUIDs, and descriptions for all dataflows in workspace
Request metadata for all datasets in specified workspace
list_datasets(workspace, access_token)list_datasets(workspace, access_token)
workspace |
Name of the workspace containing datasets |
access_token |
The token generated with the correct PowerBI Dataset permissions. Use get_az_tk('pbi_ds') to create this token. |
DataFrame containing the names, GUIDs, and descriptions for all datasets in workspace
Request metadata for all Workspaces in Tenant
list_workspaces(access_token)list_workspaces(access_token)
access_token |
The token generated with the correct PowerBI Dataset permissions. Use get_az_tk('pbi_ds') to create this token. |
DataFrame containing the names, GUIDs, and capacity GUIDs for all workspaces in tenant.
This function provides the ability to refresh PowerBI dataflows, via an R wrapper using the PowerBI REST API.
refresh_dataflow(workspace_name, dataflow_name, access_token, verbose = TRUE)refresh_dataflow(workspace_name, dataflow_name, access_token, verbose = TRUE)
workspace_name |
The PowerBI workspace name. |
dataflow_name |
The name of the PowerBI Dataflow within the workspace. |
access_token |
The token generated with the correct PowerBI Dataflow permissions. Use get_az_tk('pbi_df') to create this token. |
verbose |
Whether to print status messages while the function is running. Default is TRUE. |
A response object from the POST request.
## Not run: # Create PowerBI Dataflow azure token tk <- get_az_tk('pbi_df') # Load AD dummy file from PowerBI dataflow refresh_result <- refresh_dataflow( workspace_name = "My Workspace Name", dataflow_name = "My Dataflow Name", access_token = tk$credentials$access_token ) ## End(Not run)## Not run: # Create PowerBI Dataflow azure token tk <- get_az_tk('pbi_df') # Load AD dummy file from PowerBI dataflow refresh_result <- refresh_dataflow( workspace_name = "My Workspace Name", dataflow_name = "My Dataflow Name", access_token = tk$credentials$access_token ) ## End(Not run)