Package 'qiverse.powerbi'

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

Help Index


The qiverse.powerbi package.

Description

A collection of R functions for working with PowerBI Dataflows and Datasets

Author(s)

Maintainer: Healthcare Quality Intelligence Unit (Western Australia Health) [email protected]

See Also

Useful links:


Decode a PowerBI Compressed String

Description

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.

Usage

decompress_string(compressed_string)

Arguments

compressed_string

The base64 string of the compressed data.

Value

Original string after decompression.

Examples

table_str <- "i45W8lXSUfJNzElVitWJVnIDctxSc2HcCCDXMS+/JCO1SKEktSgXLBgKFAzNy87LL88D8/2AfL/8EoXigtTkzLTM1BSl2FgA"
decompress_string(table_str) |> cat()
# [["M","Male"],["F","Female"],["X","Another term"],["U","Unknown"],["N","Not specified"]]

Download PowerBI Dataflow Table

Description

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.

Usage

download_dataflow_table(
  workspace_name,
  dataflow_name,
  table_name,
  access_token,
  verbose = TRUE
)

Arguments

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.

Value

A data.frame of the PowerBI table from the PowerBI dataflow.

Examples

## 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)

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.

Description

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.

Usage

download_dataset_table(
  workspace,
  dataset,
  table,
  method = "XMLA",
  access_token
)

Arguments

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.

Value

DataFrame containing downloaded table


Execute a DAX query against a specified PowerBI Dataset using the REST API endpoint.

Description

Execute a DAX query against a specified PowerBI Dataset using the REST API endpoint.

Usage

execute_rest_query(workspace, dataset, query, access_token)

Arguments

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.

Value

DataFrame containing results of query


Execute a DAX query against a specified PowerBI Dataset using the XMLA API endpoint.

Description

Execute a DAX query against a specified PowerBI Dataset using the XMLA API endpoint.

Usage

execute_xmla_query(workspace, dataset, query, access_token)

Arguments

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.

Value

DataFrame containing results of query


Request metadata for all dataflows in specified workspace

Description

Request metadata for all dataflows in specified workspace

Usage

list_dataflows(workspace, access_token)

Arguments

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.

Value

DataFrame containing the names, GUIDs, and descriptions for all dataflows in workspace


Request metadata for all datasets in specified workspace

Description

Request metadata for all datasets in specified workspace

Usage

list_datasets(workspace, access_token)

Arguments

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.

Value

DataFrame containing the names, GUIDs, and descriptions for all datasets in workspace


Request metadata for all Workspaces in Tenant

Description

Request metadata for all Workspaces in Tenant

Usage

list_workspaces(access_token)

Arguments

access_token

The token generated with the correct PowerBI Dataset permissions. Use get_az_tk('pbi_ds') to create this token.

Value

DataFrame containing the names, GUIDs, and capacity GUIDs for all workspaces in tenant.


Refresh PowerBI Dataflow

Description

This function provides the ability to refresh PowerBI dataflows, via an R wrapper using the PowerBI REST API.

Usage

refresh_dataflow(workspace_name, dataflow_name, access_token, verbose = TRUE)

Arguments

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.

Value

A response object from the POST request.

Examples

## 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)