Dyota's blog

PBIR: Common Selectors

These are some common selectors for the PBIR report structure.

These assume that you are in the directory of the PBIP, such that paths like "*.Report/" are resolvable.

How did I pick up these paths? I open up the PBIP directory in VS Code, I have Malo's "Copy JSON Path" extension installed, I right click on the JSON property and copy the whole path.

Have this helper function

function Read-Json ($path) { Get-Content $path | ConvertFrom-Json -Depth 100 }

Selectors

Pages

The easiest way to target a page is by right clicking "Copy Object Name" to get the real GUID. These commands assume that the page folder names have not been altered from the defaults.

The directory that represents the page is this:

$pageGuid = ''
$pageDir = "*.Report\definition\pages\$pageGuid"

These are the page properties:

$page = Read-Json "*.Report\definition\pages\$pageGuid\page.json"

To target the page directory based on the page name, loop through all of the page directories, enter the page.json, fetch the displayName, and filter based on that property:

$pageName = ''
$pageDirs = dir "*.Report\definition\pages\*" -Directory
$pageDir = $pageDirs | ? { $page = cat "$($_.FullName)\page.json"; $page.displayName -eq $pageName }

Similarly the more definitive way of fetching a page GUID is this way (resistant to changed folder names)

$pageGuid = ''
$pageDirs = dir "*.Report\definition\pages\*" -Directory
$pageDir = $pageDirs | ? { $page = cat "$($_.FullName)\page.json"; $page.name -eq $pageGuid }

Visuals

See section on (visual types)[#visual-types] on the system names for visual types.

To select visuals of $visualType in $pageDir:

$visualDirs = dir "$($pageDir.FullName)\visuals\*" -Directory
$visualDirs | ? { $visual = Read-Json "$($_.FullName)\visual.json"; $visual.visual.visualType -eq $visualType }

Appendix

Visual types

The types of visuals are below (not comprehensive):


actionButton
advancedSlicerVisual
areaChart
barChart
card
cardVisual
clusteredBarChart
clusteredColumnChart
columnChart
donutChart
htmlContent443BE3AD55E043BF878BED274D3A6865
image
lineChart
lineClusteredColumnComboChart
pageNavigator
pieChart
pivotTable
shape
slicer
stackedAreaChart
tableEx
textbox
treemap

#pbip #pbir #powerbi #powershell