Importing Power BI projects

@prismbi/prismbi/powerbi reads a Power BI project saved as .pbip and turns it into a PrismBI model and report. To get one, use File › Save as › Power BI project in Power BI Desktop.

import { importPowerBI } from '@prismbi/prismbi/powerbi';
import { loadCsv } from '@prismbi/prismbi/connectors';

const { model, report, warnings } = importPowerBI(files, {
  data: { Sales: await loadCsv('/data/sales.csv'), Product: await loadCsv('/data/product.csv') },
});
new Report(el, { model, ...report });
console.warn(warnings); // everything that could not be imported, in plain language

files maps paths inside the project folder to their text, for example { 'Shop.SemanticModel/definition/tables/Sales.tmdl': '…', 'Shop.Report/definition/pages/…/visual.json': '…' }. In Node, read the folder recursively; in a browser, use a folder picker.

What comes across #

PartImported
Semantic model (TMDL, or model.bim in older projects)tables and typed columns, hidden flags, formats, display folders, descriptions; calculated columns and calculated tables; measures (single-line, multi-line and fenced DAX); relationships (active or inactive, single or both directions); calculation groups with their items, ordinals, precedence and format strings (static or dynamic); field parameters (as PrismBI field parameters); auto date/time tables and the fields that use them; aggregation tables (alternateOf mappings: group by, sum, min, max, count)
Report (PBIR folder format, or legacy report.json)pages in order, hidden pages, visuals with their fields, titles and positions (converted to the 12-column grid)
Visualscolumn, bar and 100% variants, line, area, stacked area, combo, ribbon, waterfall, pie, donut, treemap, funnel, scatter, card, multi-row card, KPI, gauge, table, matrix, slicer, map, filled map, decomposition tree, text box

Command line #

npx @prismbi/prismbi pbip ./Shop report.json
# 2 tables, 4 measures, 1 relationships, 3 pages, 11 visuals → report.json
#   ! Visual "a1b2" of type someCustomVisual is not supported and was skipped

The command converts the report and prints a compatibility summary. It's a quick way to check how much of a project PrismBI can run.

Lower-level pieces #