Developer Blog

Tipps und Tricks für Entwickler und IT-Interessierte

Power BI Visuals | Cookbook

Installation

Install NodeJS

Install pbiviz

npm i -g powerbi-visuals-tools@latest

Calculating of Data

Working with Highlighted values (“supportsHighlight”: true)

sumOfValues     = Object.keys(node.values).map(key => +node.values[key].value).reduce((prev, curr) => prev + curr)
sumOfHighlights = Object.keys(node.values).map(key => node.values[key].highlight ? +node.values[key].highlight : null).reduce((prev, curr) => curr ? prev + curr : null)

Get all Level Names

matrix.rows.levels.map( l => l.sources[0].displayName).join('/')

Table Tooltips

Im Repository TableSorter

Useful functions

Calculate Average of Data Points

private calculateAverage(): number {
	if (this.dataPoints.length === 0) {
		return 0;
	}

	let total = 0;
	this.dataPoints.forEach((value: ICustomDataPoint) => {
		total += <number>value.value;
	});

	return total / this.dataPoints.length;
}

capabilities.json

Alignment

        "alignment": {
          "type": {
            "formatting": {
              "alignment": true
            }
          },
          "displayName": "Horizontal Alignment"
        },

Power BI Visuals | Migration Guide

DataViewObjectsParser
import DataViewObjectsParser = powerbi.DataViewObjectsParser;
import { dataViewObjectsParser } from "powerbi-visuals-utils-dataviewutils";
import DataViewObjectsParser = dataViewObjectsParser.DataViewObjectsParser;
TextProperties
import { textMeasurementService as tms } from "powerbi-visuals-utils-formattingutils";
import TextProperties = tms.TextProperties;
import { interfaces } from "powerbi-visuals-utils-formattingutils";
import TextProperties = interfaces.TextProperties;
textMeasurementService
import { textMeasurementService as tms } from "powerbi-visuals-utils-formattingutils";
import textMeasurementService = tms.textMeasurementService;
import { textMeasurementService } from "powerbi-visuals-utils-formattingutils";
valueFormatter
import { valueFormatter as vf } from "powerbi-visuals-utils-formattingutils";
import IValueFormatter = vf.IValueFormatter;
Power BI

Power BI Visuals | Troubleshooting

powerbi.com

Can’t contact visual server

  • Use the latest version of powerbi-visuals-tools
  • pbiviz start is not running
Check https://localhost:8080/assets/status
  • Open the Page
  • Click on Advanced
  • Proceed to localhost(unsafe)
Other Reasons
  • Certificate is not valid, e.g., imported in the wrong store
  • Firewall / Norton Security active / Norton Auto-Protect active

Handle Certification Errors

Start the Visual in your development environment

Open a report the Power BI Portal with your Browser

Open the local page localhost://localhost:8080/assets