Κατανόηση της αντιστοίχισης προβολής δεδομένων σε απεικονίσεις Power BIUnderstand data view mapping in Power BI visuals
Αυτό το άρθρο εξετάζει την αντιστοίχιση προβολής δεδομένων και περιγράφει τον τρόπο με τον οποίο ρόλοι δεδομένων σχετίζονται μεταξύ τους και σας επιτρέπουν να καθορίσετε απαιτήσεις υπό όρους για αυτούς.This article discusses data view mapping and describes how data roles relate to each other and allow you to specify conditional requirements for them. Το άρθρο περιγράφει επίσης κάθε τύπο dataMappings
.The article also describes each dataMappings
type.
Κάθε έγκυρη αντιστοιχίζω παράγει μια προβολή δεδομένων, όμως προς το παρόν υποστηρίζουμε εκτέλεση μόνο ενός ερωτήματος ανά απεικόνιση.Each valid mapping produces a data view, but we currently support performing only one query per visual. Συνήθως λαμβάνετε μόνο μία προβολή δεδομένων.You ordinarily get only one data view. Ωστόσο, μπορείτε να παρέχετε πολλαπλές αντιστοιχίσεις δεδομένων σε ορισμένες συνθήκες, οι οποίες επιτρέπουν:However, you can provide multiple data mappings in certain conditions, which allow:
"dataViewMappings": [
{
"conditions": [ ... ],
"categorical": { ... },
"single": { ... },
"table": { ... },
"matrix": { ... }
}
]
Το Power BI δημιουργεί μια αντιστοίχιση σε μια προβολή δεδομένων εάν και μόνο εάν η έγκυρη αντιστοίχιση συμπληρώνεται με dataViewMappings
.Power BI creates a mapping to a data view if and only if the valid mapping is filled in dataViewMappings
.
Με άλλα λόγια, το categorical
μπορεί να έχει οριστεί σε dataViewMappings
, όμως άλλες αντιστοιχίσεις όπως table
ή single
, μπορεί να μην έχουν οριστεί.In other words, categorical
might be defined in dataViewMappings
but other mappings, such as table
or single
, might not be. Για παράδειγμα:For example:
"dataViewMappings": [
{
"categorical": { ... }
}
]
Το Power BI παράγει μια προβολή δεδομένων με μια μεμονωμένη αντιστοίχιση categorical
και table
, και άλλες αντιστοιχίσεις δεν έχουν οριστεί:Power BI produces a data view with a single categorical
mapping, and table
and other mappings are undefined:
{
"categorical": {
"categories": [ ... ],
"values": [ ... ]
},
"metadata": { ... }
}
ΣυνθήκεςConditions
Αυτή η ενότητα περιγράφει συνθήκες για μια συγκεκριμένη αντιστοίχιση δεδομένων.This section describes conditions for a particular data mapping. Μπορείτε να παρέχετε πολλά σύνολα συνθηκών και, αν τα δεδομένα συμφωνούν με ένα από τα σύνολα συνθηκών που περιγράφονται, η απεικόνιση αποδέχεται τα δεδομένα ως έγκυρα.You can provide multiple sets of conditions and, if the data matches one of the described sets of conditions, the visual accepts the data as valid.
Προς το παρόν, για κάθε πεδίο, μπορείτε να καθορίσετε μια ελάχιστη και μέγιστη τιμή.Currently, for each field, you can specify a minimum and maximum value. Η τιμή αντιπροσωπεύει τον αριθμό των πεδίων που μπορούν να συνδεθούν με αυτόν τον ρόλο δεδομένων.The value represents the number of fields that can be bound to that data role.
Σημείωση
Εάν παραλειφθεί ένας ρόλος δεδομένων στη συνθήκη, μπορεί να έχει οποιονδήποτε αριθμό πεδίων.If a data role is omitted in the condition, it can have any number of fields.
Παράδειγμα 1Example 1
Μπορείτε να σύρετε πολλά πεδία σε κάθε ρόλο δεδομένων.You can drag multiple fields into each data role. Σε αυτό το παράδειγμα, περιορίζετε την κατηγορία σε ένα πεδίο δεδομένων και τη μέτρηση σε δύο πεδία δεδομένων.In this example, you limit the category to one data field and the measure to two data fields.
"conditions": [
{ "category": { "max": 1 }, "y": { "max": 2 } },
]
Παράδειγμα 2Example 2
Σε αυτό το παράδειγμα, απαιτείται οποιαδήποτε από τις δύο συνθήκες:In this example, either of two conditions is required:
- Ακριβώς ένα πεδίο δεδομένων κατηγορίας και ακριβώς δύο μετρήσειςExactly one category data field and exactly two measures
- Ακριβώς δύο κατηγορίες και ακριβώς μία μέτρηση.Exactly two categories and exactly one measure.
"conditions": [
{ "category": { "min": 1, "max": 1 }, "measure": { "min": 2, "max": 2 } },
{ "category": { "min": 2, "max": 2 }, "measure": { "min": 1, "max": 1 } }
]
Μεμονωμένη αντιστοίχιση δεδομένωνSingle data mapping
Η μεμονωμένη αντιστοίχιση δεδομένων είναι η απλούστερη μορφή αντιστοίχισης δεδομένων.Single data mapping is the simplest form of data mapping. Αποδέχεται ένα πεδίο μεμονωμένης μέτρησης και σας δίνει το σύνολο.It accepts a single measure field and gives you the total. Εάν το πεδίο είναι αριθμητικό, σας δίνει το άθροισμα.If the field is numeric, it gives you the sum. Διαφορετικά, σας δίνει ένα πλήθος μοναδικών τιμών.Otherwise, it gives you a count of unique values.
Για να χρησιμοποιήσετε μια μεμονωμένη αντιστοίχιση δεδομένων, πρέπει να ορίσετε το όνομα του ρόλου δεδομένων που θέλετε να αντιστοιχίσετε.To use single data mapping, you need to define the name of the data role that you want to map. Αυτή η αντιστοίχιση λειτουργεί μόνο με ένα μοναδικό πεδίο μέτρησης.This mapping works only with a single measure field. Εάν ανατεθεί ένα δεύτερο πεδίο, δεν δημιουργείται καμία προβολή δεδομένων, επομένως είναι καλό να συμπεριλάβετε μια συνθήκη που περιορίζει τα δεδομένα σε ένα μοναδικό πεδίο.If a second field is assigned, no data view is generated, so it's also a good practice to include a condition that limits the data to a single field.
Σημείωση
Αυτή η αντιστοίχιση δεδομένων δεν μπορεί να χρησιμοποιηθεί σε συνδυασμό με οποιαδήποτε άλλη αντιστοίχιση δεδομένων.This data mapping can't be used in conjunction with any other data mapping. Προορίζεται να περιορίσει τα δεδομένα σε μία μόνο αριθμητική τιμή.It's meant to reduce data into a single numeric value.
Παράδειγμα 3Example 3
{
"dataRoles": [
{
"displayName": "Y",
"name": "Y",
"kind": "Measure"
}
],
"dataViewMappings": [
{
"conditions": [
{
"Y": {
"max": 1
}
}
],
"single": {
"role": "Y"
}
}
]
}
Η προβολή δεδομένων που προκύπτει εξακολουθεί να περιέχει τους άλλους τύπους (πίνακας, κατηγορικό και ούτω καθεξής), όμως κάθε αντιστοίχιση περιέχει μόνο τη μοναδική τιμή.The resulting data view still contains the other types (table, categorical, and so on), but each mapping contains only the single value. Η βέλτιστη πρακτική είναι πρόσβαση στην τιμή μόνο μεμονωμένα.The best practice is to access the value only in single.
{
"dataView": [
{
"metadata": null,
"categorical": null,
"matrix": null,
"table": null,
"tree": null,
"single": {
"value": 94163140.3560001
}
}
]
}
Δείγμα κώδικα για την επεξεργασία απλής αντιστοίχισης προβολής δεδομένωνCode sample to process simple data view mapping
"use strict";
import powerbi from "powerbi-visuals-api";
import DataView = powerbi.DataView;
import DataViewSingle = powerbi.DataViewSingle;
// standart imports
// ...
export class Visual implements IVisual {
private target: HTMLElement;
private host: IVisualHost;
private valueText: HTMLParagraphElement;
constructor(options: VisualConstructorOptions) {
// constructor body
this.target = options.element;
this.host = options.host;
this.valueText = document.createElement("p");
this.target.appendChild(this.valueText);
// ...
}
public update(options: VisualUpdateOptions) {
const dataView: DataView = options.dataViews[0];
const singleDataView: DataViewSingle = dataView.single;
if (!singleDataView ||
!singleDataView.value ) {
return
}
this.valueText.innerText = singleDataView.value.toString();
}
}
Κατά συνέπεια, η απεικόνιση εμφανίζει μια μεμονωμένη τιμή από το Power BI:As a result the visual displays a single value from Power BI:
Αντιστοίχιση κατηγορικών δεδομένωνCategorical data mapping
Η αντιστοίχιση κατηγορηματικών δεδομένων χρησιμοποιείται για τη λήψη ενός ή δύο ανεξάρτητων ομαδοποιήσεων δεδομένων.Categorical data mapping is used to get one or two independent groupings of data.
Παράδειγμα 4Example 4
Δείτε τον ορισμό από το προηγούμενο παράδειγμα για ρόλους δεδομένων:Here is the definition from the previous example for data roles:
"dataRole":[
{
"displayName": "Category",
"name": "category",
"kind": "Grouping"
},
{
"displayName": "Y Axis",
"name": "measure",
"kind": "Measure"
}
]
Δείτε την αντιστοίχιση:Here is the mapping:
"dataViewMappings": {
"categorical": {
"categories": {
"for": { "in": "category" }
},
"values": {
"select": [
{ "bind": { "to": "measure" } }
]
}
}
}
Είναι ένα απλό παράδειγμα.It's a simple example. Λέει "Να γίνει αντιστοίχιση του ρόλου δεδομένων μου category
ώστε για κάθε πεδίο που μεταφέρω στο category
, τα δεδομένα του να αντιστοιχίζουν σε categorical.categories
.It reads "Map my category
data role so that for every field I drag into category
, its data is mapped to categorical.categories
. Αντιστοιχίστε επίσης τον ρόλο δεδομένων μου measure
σε categorical.values
."Also map my measure
data role to categorical.values
."
- for...in: Για όλα τα στοιχεία σε αυτόν τον ρόλο δεδομένων, συμπεριλάβετέ τα στο ερώτημα δεδομένων.for...in: For all the items in this data role, include them in the data query.
- bind...to: Παράγει το ίδιο αποτέλεσμα με το for...in, αλλά αναμένει ότι ο ρόλος δεδομένων θα έχει μια συνθήκη περιορισμού σε ένα μοναδικό πεδίο.bind...to: Produces the same result as in for...in, but expects that the data role will have a condition restricting it to a single field.
Παράδειγμα 5Example 5
Αυτό το παράδειγμα χρησιμοποιεί τους δύο πρώτους ρόλους δεδομένων από το προηγούμενο παράδειγμα και επιπλέον ορίζει τα grouping
και measure2
.This example uses the first two data roles from the previous example and additionally defines grouping
and measure2
.
"dataRole":[
{
"displayName": "Category",
"name": "category",
"kind": "Grouping"
},
{
"displayName": "Y Axis",
"name": "measure",
"kind": "Measure"
},
{
"displayName": "Grouping with",
"name": "grouping",
"kind": "Grouping"
},
{
"displayName": "X Axis",
"name": "measure2",
"kind": "Grouping"
}
]
Δείτε την αντιστοίχιση:Here is the mapping:
"dataViewMappings":{
"categorical": {
"categories": {
"for": { "in": "category" }
},
"values": {
"group": {
"by": "grouping",
"select":[
{ "bind": { "to": "measure" } },
{ "bind": { "to": "measure2" } }
]
}
}
}
}
Εδώ η διαφορά αφορά τον τρόπο αντιστοίχισης κατηγορικών τιμών.Here the difference is in how we are mapping categorical.values. Λέμε "Να γίνει αντιστοίχιση των ρόλων δεδομένων μου measure
και measure2
για να ομαδοποιηθούν από τον ρόλο δεδομένων grouping
".We are saying that "Map my measure
and measure2
data roles to be grouped by the data role grouping
."
Παράδειγμα 6Example 6
Δείτε τους ρόλους δεδομένων:Here are the data roles:
"dataRoles": [
{
"displayName": "Categories",
"name": "category",
"kind": "Grouping"
},
{
"displayName": "Measures",
"name": "measure",
"kind": "Measure"
},
{
"displayName": "Series",
"name": "series",
"kind": "Measure"
}
]
Δείτε την αντιστοίχιση προβολής δεδομένων:Here is the data view mapping:
"dataViewMappings": [
{
"categorical": {
"categories": {
"for": {
"in": "category"
}
},
"values": {
"group": {
"by": "series",
"select": [{
"for": {
"in": "measure"
}
}
]
}
}
}
}
]
Η προβολή κατηγορικών δεδομένων μπορεί να απεικονιστεί ως εξής:The categorical data view could be visualized like this:
ΧώραCountry | 20132013 | 20142014 | 20152015 | 20162016 |
---|---|---|---|---|
ΗΠΑUSA | xx | xx | 650650 | 350350 |
ΚαναδάςCanada | xx | 630630 | 490490 | xx |
ΜεξικόMexico | 645645 | xx | xx | xx |
Ηνωμένο ΒασίλειοUK | xx | xx | 831831 | xx |
Παράγεται από το Power BI ως η προβολή κατηγορικών δεδομένων.Power BI produces it as the categorical data view. Είναι το σύνολο των κατηγοριών.It's the set of categories.
{
"categorical": {
"categories": [
{
"source": {...},
"values": [
"Canada",
"USA",
"UK",
"Mexico"
],
"identity": [...],
"identityFields": [...],
}
]
}
}
Κάθε κατηγορία αντιστοιχεί επίσης σε ένα σύνολο τιμών.Each category maps to a set of values as well. Καθεμία από αυτές τις τιμές ομαδοποιείται κατά σειρά, που εκφράζεται σε έτη.Each of these values is grouped by series, which is expressed as years.
Για παράδειγμα, κάθε πίνακας values
αντιπροσωπεύει δεδομένα για κάθε έτος.For example, each values
array represents data for each year.
Επίσης, κάθε πίνακας values
έχει 4 τιμές, για Καναδά, ΗΠΑ, Ηνωμένο Βασίλειο και Μεξικό αντίστοιχα:Also each values
array has 4 values, for Canada, USA, UK and Mexico respectively:
{
"values": [
// Values for 2013 year
{
"source": {...},
"values": [
null, // Value for `Canada` category
null, // Value for `USA` category
null, // Value for `UK` category
645 // Value for `Mexico` category
],
"identity": [...],
},
// Values for 2014 year
{
"source": {...},
"values": [
630, // Value for `Canada` category
null, // Value for `USA` category
null, // Value for `UK` category
null // Value for `Mexico` category
],
"identity": [...],
},
// Values for 2015 year
{
"source": {...},
"values": [
490, // Value for `Canada` category
650, // Value for `USA` category
831, // Value for `UK` category
null // Value for `Mexico` category
],
"identity": [...],
},
// Values for 2016 year
{
"source": {...},
"values": [
null, // Value for `Canada` category
350, // Value for `USA` category
null, // Value for `UK` category
null // Value for `Mexico` category
],
"identity": [...],
}
]
}
Παρακάτω περιγράφει το δείγμα κώδικα για την επεξεργασία αντιστοίχισης προβολής κατηγορικών δεδομένων.Code sample for processing categorical data view mapping is described below. Το δείγμα δημιουργεί Ιεραρχική δομή Country => Year => Value
The sample creates Hierarchical structure Country => Year => Value
"use strict";
import powerbi from "powerbi-visuals-api";
import DataView = powerbi.DataView;
import DataViewCategorical = powerbi.DataViewCategorical;
import DataViewValueColumnGroup = powerbi.DataViewValueColumnGroup;
import PrimitiveValue = powerbi.PrimitiveValue;
// standart imports
// ...
export class Visual implements IVisual {
private target: HTMLElement;
private host: IVisualHost;
private categories: HTMLElement;
constructor(options: VisualConstructorOptions) {
// constructor body
this.target = options.element;
this.host = options.host;
this.categories = document.createElement("pre");
this.target.appendChild(this.categories);
// ...
}
public update(options: VisualUpdateOptions) {
const dataView: DataView = options.dataViews[0];
const categoricalDataView: DataViewCategorical = dataView.categorical;
if (!categoricalDataView ||
!categoricalDataView.categories ||
!categoricalDataView.categories[0] ||
!categoricalDataView.values) {
return;
}
// Categories have only one column in data buckets
// If you want to support several columns of categories data bucket, you should iterate categoricalDataView.categories array.
const categoryFieldIndex = 0;
// Measure has only one column in data buckets.
// If you want to support several columns on data bucket, you should iterate years.values array in map function
const measureFieldIndex = 0;
let categories: PrimitiveValue[] = categoricalDataView.categories[categoryFieldIndex].values;
let values: DataViewValueColumnGroup[] = categoricalDataView.values.grouped();
let data = {};
// iterate categories/countries
categories.map((category: PrimitiveValue, categoryIndex: number) => {
data[category.toString()] = {};
// iterate series/years
values.map((years: DataViewValueColumnGroup) => {
if (!data[category.toString()][years.name] && years.values[measureFieldIndex].values[categoryIndex]) {
data[category.toString()][years.name] = []
}
if (years.values[0].values[categoryIndex]) {
data[category.toString()][years.name].push(years.values[measureFieldIndex].values[categoryIndex]);
}
});
});
this.categories.innerText = JSON.stringify(data, null, 6);
console.log(data);
}
}
Το αποτέλεσμα της απεικόνισης:The result of the visual:
Αντιστοίχιση δεδομένων πίνακαTable data mapping
Η προβολή δεδομένων πίνακα είναι μια απλή αντιστοίχιση δεδομένων.The table data view is a simple data mapping. Ουσιαστικά, είναι μια λίστα σημείων δεδομένων, όπου τα αριθμητικά σημεία δεδομένων μπορούν να συγκεντρωθούν.Essentially, it's a list of data points, where numeric data points could be aggregated.
Παράδειγμα 7Example 7
Με τις δεδομένες δυνατότητες:With the given capabilities:
"dataRoles": [
{
"displayName": "Column",
"name": "column",
"kind": "Grouping"
},
{
"displayName": "Value",
"name": "value",
"kind": "Measure"
}
]
"dataViewMappings": [
{
"table": {
"rows": {
"select": [
{
"for": {
"in": "column"
}
},
{
"for": {
"in": "value"
}
}
]
}
}
}
]
Μπορείτε να απεικονίσετε την προβολή δεδομένων πίνακα ως εξής:You can visualize the table data view as the following:
Παράδειγμα δεδομένων:Data example:
ΧώραCountry | ΈτοςYear | SalesSales |
---|---|---|
ΗΠΑUSA | 20162016 | 100100 |
ΗΠΑUSA | 20152015 | 5050 |
ΚαναδάςCanada | 20152015 | 200200 |
ΚαναδάςCanada | 20152015 | 5050 |
ΜεξικόMexico | 20132013 | 300300 |
Ηνωμένο ΒασίλειοUK | 20142014 | 150150 |
ΗΠΑUSA | 20152015 | 7575 |
Σύνδεση δεδομένων:Data binding:
Το Power BI εμφανίζει τα δεδομένα σας ως προβολή δεδομένων πίνακα.Power BI displays your data as the table data view. Δεν θα πρέπει να υποθέσετε ότι τα δεδομένα είναι ταξινομημένα.You shouldn't assume that the data is ordered.
{
"table" : {
"columns": [...],
"rows": [
[
"Canada",
2014,
630
],
[
"Canada",
2015,
490
],
[
"Mexico",
2013,
645
],
[
"UK",
2014,
831
],
[
"USA",
2015,
650
],
[
"USA",
2016,
350
]
]
}
}
Μπορείτε να συγκεντρώσετε τα δεδομένα επιλέγοντας το επιθυμητό πεδίο και, στη συνέχεια, επιλέγοντας άθροισμα.You can aggregate the data by selecting the desired field and then selecting sum.
Δείγμα κώδικα για την επεξεργασία της αντιστοίχισης προβολής δεδομένων πίνακα.Code sample to process table data view mapping.
"use strict";
import "./../style/visual.less";
import powerbi from "powerbi-visuals-api";
// ...
import DataViewMetadataColumn = powerbi.DataViewMetadataColumn;
import DataViewTable = powerbi.DataViewTable;
import DataViewTableRow = powerbi.DataViewTableRow;
import PrimitiveValue = powerbi.PrimitiveValue;
// other imports
// ...
export class Visual implements IVisual {
private target: HTMLElement;
private host: IVisualHost;
private table: HTMLParagraphElement;
constructor(options: VisualConstructorOptions) {
// constructor body
this.target = options.element;
this.host = options.host;
this.table = document.createElement("table");
this.target.appendChild(this.table);
// ...
}
public update(options: VisualUpdateOptions) {
const dataView: DataView = options.dataViews[0];
const tableDataView: DataViewTable = dataView.table;
if (!tableDataView) {
return
}
while(this.table.firstChild) {
this.table.removeChild(this.table.firstChild);
}
//draw header
const tableHeader = document.createElement("th");
tableDataView.columns.forEach((column: DataViewMetadataColumn) => {
const tableHeaderColumn = document.createElement("td");
tableHeaderColumn.innerText = column.displayName
tableHeader.appendChild(tableHeaderColumn);
});
this.table.appendChild(tableHeader);
//draw rows
tableDataView.rows.forEach((row: DataViewTableRow) => {
const tableRow = document.createElement("tr");
row.forEach((columnValue: PrimitiveValue) => {
const cell = document.createElement("td");
cell.innerText = columnValue.toString();
tableRow.appendChild(cell);
})
this.table.appendChild(tableRow);
});
}
}
Το αρχείο στυλ απεικόνισης style/visual.less
περιέχει διάταξη για τον πίνακα:The visual styles file style/visual.less
contains layout for table:
table {
display: flex;
flex-direction: column;
}
tr, th {
display: flex;
flex: 1;
}
td {
flex: 1;
border: 1px solid black;
}
Αντιστοίχιση δεδομένων μήτραςMatrix data mapping
Η αντιστοίχιση δεδομένων μήτρας είναι παρόμοια με την αντιστοίχιση δεδομένων πίνακα, αλλά οι γραμμές παρουσιάζονται με ιεραρχική σειρά.Matrix data mapping is similar to table data mapping, but the rows are presented hierarchically. Οποιεσδήποτε από τις τιμές ρόλου δεδομένων μπορεί να χρησιμοποιηθεί ως τιμή κεφαλίδας στήλης.Any of the data role values can be used as a column header value.
{
"dataRoles": [
{
"name": "Category",
"displayName": "Category",
"displayNameKey": "Visual_Category",
"kind": "Grouping"
},
{
"name": "Column",
"displayName": "Column",
"displayNameKey": "Visual_Column",
"kind": "Grouping"
},
{
"name": "Measure",
"displayName": "Measure",
"displayNameKey": "Visual_Values",
"kind": "Measure"
}
],
"dataViewMappings": [
{
"matrix": {
"rows": {
"for": {
"in": "Category"
}
},
"columns": {
"for": {
"in": "Column"
}
},
"values": {
"select": [
{
"for": {
"in": "Measure"
}
}
]
}
}
}
]
}
Το Power BI δημιουργεί μια ιεραρχική δομή δεδομένων.Power BI creates a hierarchical data structure. Η ρίζα της ιεραρχίας δέντρου περιλαμβάνει τα δεδομένα από τη στήλη Γονικά στοιχεία του ρόλου δεδομένων Category
, με θυγατρικά στοιχεία από τη στήλη Θυγατρικά στοιχεία του πίνακα ρόλου δεδομένων.The root of the tree hierarchy includes the data from the Parents column of the Category
data role, with children from the Children column of the data role table.
Dataset:Dataset:
ParentsParents | ChildrenChildren | GrandchildrenGrandchildren | ΣτήλεςColumns | ΤιμέςValues |
---|---|---|---|---|
Parent1Parent1 | Child1Child1 | Grand child1Grand child1 | Col1Col1 | 55 |
Parent1Parent1 | Child1Child1 | Grand child1Grand child1 | Col2Col2 | 66 |
Parent1Parent1 | Child1Child1 | Grand child2Grand child2 | Col1Col1 | 77 |
Parent1Parent1 | Child1Child1 | Grand child2Grand child2 | Col2Col2 | 88 |
Parent1Parent1 | Child2Child2 | Grand child3Grand child3 | Col1Col1 | 55 |
Parent1Parent1 | Child2Child2 | Grand child3Grand child3 | Col2Col2 | 33 |
Parent1Parent1 | Child2Child2 | Grand child4Grand child4 | Col1Col1 | 44 |
Parent1Parent1 | Child2Child2 | Grand child4Grand child4 | Col2Col2 | 99 |
Parent1Parent1 | Child2Child2 | Grand child5Grand child5 | Col1Col1 | 33 |
Parent1Parent1 | Child2Child2 | Grand child5Grand child5 | Col2Col2 | 55 |
Parent2Parent2 | Child3Child3 | Grand child6Grand child6 | Col1Col1 | 11 |
Parent2Parent2 | Child3Child3 | Grand child6Grand child6 | Col2Col2 | 22 |
Parent2Parent2 | Child3Child3 | Grand child7Grand child7 | Col1Col1 | 77 |
Parent2Parent2 | Child3Child3 | Grand child7Grand child7 | Col2Col2 | 11 |
Parent2Parent2 | Child3Child3 | Grand child8Grand child8 | Col1Col1 | 1010 |
Parent2Parent2 | Child3Child3 | Grand child8Grand child8 | Col2Col2 | 1313 |
Η απεικόνιση μήτρας πυρήνα του Power BI αποδίδει τα δεδομένα ως πίνακα.The core matrix visual of Power BI renders the data as a table.
Η απεικόνιση λαμβάνει τη δομή δεδομένων της όπως περιγράφεται στον παρακάτω κώδικα (μόνο οι δύο πρώτες γραμμές πίνακα εμφανίζονται εδώ):The visual gets its data structure as described in the following code (only the first two table rows are shown here):
{
"metadata": {...},
"matrix": {
"rows": {
"levels": [...],
"root": {
"childIdentityFields": [...],
"children": [
{
"level": 0,
"levelValues": [...],
"value": "Parent1",
"identity": {...},
"childIdentityFields": [...],
"children": [
{
"level": 1,
"levelValues": [...],
"value": "Child1",
"identity": {...},
"childIdentityFields": [...],
"children": [
{
"level": 2,
"levelValues": [...],
"value": "Grand child1",
"identity": {...},
"values": {
"0": {
"value": 5 // value for Col1
},
"1": {
"value": 6 // value for Col2
}
}
},
...
]
},
...
]
},
...
]
}
},
"columns": {
"levels": [...],
"root": {
"childIdentityFields": [...],
"children": [
{
"level": 0,
"levelValues": [...],
"value": "Col1",
"identity": {...}
},
{
"level": 0,
"levelValues": [...],
"value": "Col2",
"identity": {...}
},
...
]
}
},
"valueSources": [...]
}
}
Αλγόριθμος μείωσης δεδομένωνData reduction algorithm
Για να ελέγξετε το πλήθος δεδομένων που θα λάβετε στην προβολή δεδομένων, μπορείτε να εφαρμόσετε έναν αλγόριθμο μείωσης δεδομένων.To control the amount of data to receive in the data view, you can apply a data reduction algorithm.
Από προεπιλογή, σε όλες οι απεικονίσεις Power BI έχει εφαρμοστεί ο αλγόριθμος μείωσης κορυφαίων δεδομένων με την τιμή count να έχει οριστεί στα 1000 σημεία δεδομένων.By default, all Power BI visuals have the top data reduction algorithm applied with the count set to 1000 data points. Είναι ίδιο με τη ρύθμιση των ακόλουθων ιδιοτήτων στο αρχείο capabilities.json:It's the same as setting the following properties in the capabilities.json file:
"dataReductionAlgorithm": {
"top": {
"count": 1000
}
}
Μπορείτε να τροποποιήσετε την τιμή count σε οποιαδήποτε ακέραια τιμή έως και 30000.You can modify the count value to any integer value up to 30000. Οι απεικονίσεις Power BI που βασίζονται σε R μπορούν να υποστηρίζουν έως 150.000 γραμμές.R-based Power BI visuals can support up to 150000 rows.
Τύποι αλγόριθμου μείωσης δεδομένωνData reduction algorithm types
Υπάρχουν τέσσερις τύποι ρυθμίσεων αλγορίθμου μείωσης δεδομένων:There are four types of data reduction algorithm settings:
top
: Εάν θέλετε να περιορίσετε τα δεδομένα σε τιμές που λαμβάνονται από το επάνω μέρος του συνόλου δεδομένων.top
: If you want to limit the data to values taken from the top of the dataset. Οι κορυφαίες πρώτες τιμές count θα λαμβάνονται από το σύνολο δεδομένων.The top first count values will be taken from the dataset.bottom
: Εάν θέλετε να περιορίσετε τα δεδομένα σε τιμές που λαμβάνονται από το κάτω μέρος του συνόλου δεδομένων.bottom
: If you want to limit the data to values taken from the bottom of the dataset. Οι τελευταίες τιμές "count" θα ληφθούν από το σύνολο δεδομένων.The last "count" values will be taken from the dataset.sample
: Μειώστε το σύνολο δεδομένων με έναν απλό αλγόριθμο δειγματοληψίας, ο οποίος περιορίζεται σε έναν αριθμό στοιχείων count.sample
: Reduce the dataset by a simple sampling algorithm, limited to a count number of items. Αυτό σημαίνει ότι περιλαμβάνονται τα πρώτα και τελευταία στοιχεία και ένας αριθμός στοιχείων count με ίσα διαστήματα μεταξύ τους.It means that the first and last items are included, and a count number of items have equal intervals between them. Για παράδειγμα, εάν έχετε ένα σύνολο δεδομένων [0, 1, 2, ... 100] και ένα πλήθος 9, θα λάβετε τις τιμές [0, 10, 20 ... 100].For example, if you have a dataset [0, 1, 2, ... 100] and a count of 9, you'll receive the values [0, 10, 20 ... 100].window
: Φορτώνει ένα window σημείων δεδομένων τη φορά που περιέχει count στοιχεία.window
: Loads one window of data points at a time containing count elements. Προς το παρόν, ταtop
καιwindow
είναι ισοδύναμα.Currently,top
andwindow
are equivalent. Εργαζόμαστε με στόχο την πλήρη υποστήριξη μιας ρύθμισης παραθύρων.We are working toward fully supporting a windowing setting.
Χρήση αλγόριθμου μείωσης δεδομένωνData reduction algorithm usage
Ο αλγόριθμος μείωσης δεδομένων μπορεί να χρησιμοποιηθεί σε αντιστοίχιση προβολής δεδομένων κατηγορική, πίνακα ή μήτρας.The data reduction algorithm can be used in categorical, table, or matrix data view mapping.
Μπορείτε να ορίσετε τον αλγόριθμο σε categories
ή/και ενότητα ομάδας values
για αντιστοίχιση κατηγορικών δεδομένων.You can set the algorithm into categories
and/or group section of values
for categorical data mapping.
Παράδειγμα 8Example 8
"dataViewMappings": {
"categorical": {
"categories": {
"for": { "in": "category" },
"dataReductionAlgorithm": {
"window": {
"count": 300
}
}
},
"values": {
"group": {
"by": "series",
"select": [{
"for": {
"in": "measure"
}
}
],
"dataReductionAlgorithm": {
"top": {
"count": 100
}
}
}
}
}
}
Μπορείτε να εφαρμόσετε τον αλγόριθμο μείωσης δεδομένων στην ενότητα rows
του πίνακα αντιστοίχισης προβολής δεδομένων.You can apply the data reduction algorithm to the rows
section of the Data View mapping table.
Παράδειγμα 9Example 9
"dataViewMappings": [
{
"table": {
"rows": {
"for": {
"in": "values"
},
"dataReductionAlgorithm": {
"top": {
"count": 2000
}
}
}
}
}
]
Μπορείτε να εφαρμόσετε τον αλγόριθμο μείωσης δεδομένων στις ενότητες rows
και columns
της μήτρας αντιστοίχισης προβολής δεδομένων.You can apply the data reduction algorithm to the rows
and columns
sections of the Data View mapping matrix.
Επόμενα βήματαNext steps
Διαβάστε πληροφορίες για την προσθήκη υποστήριξης διερεύνησης για αντιστοιχίσεις προβολής δεδομένων σε απεικονίσεις Power BI.Read how to add Drill-Down support for data view mappings in Power BI visuals.