Contains JavaScript & TypeScript object models for Microsoft Power BI JavaScript SDK
Перейти к файлу
Tuoheng Yu 5b67673543 Merged PR 349480: Version Bump for quick create default aggregate
Version Bump since client change for quick create default aggregate is deployed to canary 1 and 2
2023-02-01 09:59:36 -08:00
.config/merlinbot Merged PR 178692: Add merlin config 2021-06-15 06:39:46 +00:00
.pipelines Merged PR 311058: Adding OneBranch pipeline YAML config file for powerbi-models-Official 2022-11-13 14:40:15 +00:00
src Merged PR 336581: [Quick Create]Add aggregateFunction to ColumnSchema 2023-02-01 09:59:36 -08:00
test Merged PR 326553: Add missing advanced filter operators 2023-01-24 11:51:12 +00:00
.eslintignore Merged PR 260487: Migrate the powerbi-models library from TSLint to ESLint 2022-05-23 16:04:03 +03:00
.eslintrc.js Merged PR 267928: Fix broken powerbi-models@1.10.1 - Release version 1.10.2 2022-05-29 14:05:15 +00:00
.gitignore Merged PR 269241: Adding package-lock.json 2022-05-31 10:32:42 +00:00
.npmrc Remediating Azure Artifacts Configuration Issues in your Repository 2022-09-01 13:18:36 +00:00
.travis.yml
CONTRIBUTING.md Merged PR 266897: Merged PR 265476: [powerbi-models] Fix remaining vulnerabilities 2022-05-23 13:10:03 +00:00
LICENSE.txt
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 260487: Migrate the powerbi-models library from TSLint to ESLint 2022-05-23 16:04:03 +03:00
karma.conf.js Merged PR 139687: Add kjhtml 2021-01-18 07:00:11 +00:00
owners.txt resolve conflict 2022-05-02 13:33:04 +03:00
package-lock.json Merged PR 349480: Version Bump for quick create default aggregate 2023-02-01 09:59:36 -08:00
package.json Merged PR 349480: Version Bump for quick create default aggregate 2023-02-01 09:59:36 -08:00
tsconfig.json Merged PR 267928: Fix broken powerbi-models@1.10.1 - Release version 1.10.2 2022-05-29 14:05:15 +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 267928: Fix broken powerbi-models@1.10.1 - Release version 1.10.2 2022-05-29 14:05:15 +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"
    }
  ]
}