Contains JavaScript & TypeScript object models for Microsoft Power BI JavaScript SDK
Перейти к файлу
Shahak Yosef cf4ca26550 Merged PR 179302: Version 1.9.1
Version 1.9.1
2021-06-16 12:08:02 +00:00
.config/merlinbot Merged PR 178692: Add merlin config 2021-06-15 06:39:46 +00:00
.pipelines Merged PR 99488: [CDPx] Pipeline build artifacts fix 2020-07-13 12:22:21 +00:00
.vscode Merged PR 130054: [powerbi-models]: Make master up-to-date with portal 2020-11-30 04:57:39 +00:00
src Merged PR 178687: Custom Visuals: Add Support Of "Group On key" 2021-06-15 11:59:56 +00:00
test Merged PR 147041: [RDL Embed] Parameter panel settings 2021-02-16 09:22:31 +00:00
.gitignore Merged PR 3737: remove package lock 2018-01-02 12:28:07 +00:00
.travis.yml skip cleanup to ensure npm modules exists. 2017-10-15 16:16:32 +03:00
CONTRIBUTING.md Merged PR 130054: [powerbi-models]: Make master up-to-date with portal 2020-11-30 04:57:39 +00:00
LICENSE.txt Initial Commit of powerbi-models. Has interfaces which are shared between host and iframe code. 2016-06-23 11:34:44 -07:00
README.md Merged PR 130054: [powerbi-models]: Make master up-to-date with portal 2020-11-30 04:57:39 +00:00
SECURITY.md Merged PR 144019: Added SECURITY.md 2021-02-03 12:47:02 +00:00
gulpfile.js Merged PR 145114: Improve kjhtml 2021-02-07 08:46:48 +00:00
karma.conf.js Merged PR 139687: Add kjhtml 2021-01-18 07:00:11 +00:00
package.json Merged PR 179302: Version 1.9.1 2021-06-16 12:08:02 +00:00
tsconfig.json Merged PR 130054: [powerbi-models]: Make master up-to-date with portal 2020-11-30 04:57:39 +00:00
tslint.json Merged PR 130054: [powerbi-models]: Make master up-to-date with portal 2020-11-30 04:57:39 +00:00
typings.json Merged PR 130054: [powerbi-models]: Make master up-to-date with portal 2020-11-30 04:57:39 +00:00
webpack.config.js initial commit 2020-12-30 09:10:30 +02:00
webpack.test.config.js Merged PR 143202: Add capture all pages option to bookmark capture options 2021-02-02 16:05:08 +00:00
webpack.test.tsconfig.json Merged PR 130054: [powerbi-models]: Make master up-to-date with portal 2020-11-30 04:57:39 +00:00

README.md

powerbi-models

Build Status NPM Version NPM Total Downloads NPM Monthly Downloads GitHub tag

Contains JavaScript & TypeScript object models for Microsoft Power BI JavaScript SDK.

For each model there is a TypeScript interface, a json schema definitions, and a validation function to ensure a given object is a valid model.

Documentation

https://microsoft.github.io/powerbi-models

Getting Started

Install

npm install --save powerbi-models

Import

import * as models from 'powerbi-models';

Usage

Validation:

let testObject = { x: 1 };

const errors = models.validateLoad(testObject);

if(errors) {
  console.warn(errors);
}

Would output to the console:

[
  {
    message: 'accessToken is required'
  }
]

Creating filters:

const basicFilter: models.IBasicFilter = {
  target: {
    table: "Products",
    column: "Version"
  },
  operator: "In",
  values: [
    1,
    2,
    3,
    4
  ]
};

const advancedFilter: models.IAdvancedFilter = {
  target: {
    table: "Products",
    column: "Name"
  },
  logicalOperator: "Or",
  conditions: [
    {
      operator: "Contains",
      value: "Power"
    },
    {
      operator: "Contains",
      value: "Microsoft"
    }
  ]
};

Or use the constructor methods:

const advancedFilter = new models.AdvancedFilter(
  {
    table: "Products",
    column: "Name"
  },
  "Or",
  {
    operator: "Contains",
    value: "Power"
  },
  {
    operator: "Contains",
    value: "Microsoft"
  }
);

Date Formatting

Dates should be formated using ISO 8601 standard. Example: 2016-09-08T00:15:46.861Z

This is how dates are naturally serialized to JSON:

new Date().toJSON(); //=> 2016-09-08T00:15:46.861Z

An example filter using this Date format would look like the following:

{
  "$schema": "http://powerbi.com/product/schema#advanced",
  "target": {
    "table": "Time",
    "column": "Date"
  },
  "logicalOperator": "And",
  "conditions": [
    {
      "operator": "GreaterThan",
      "value": "2014-06-01T07:00:00.000Z"
    }
  ]
}