Forum Discussion
Possible Bug in d3.scaling | EDIT: How to void grouping/categorizing data
- 8 years ago
This is expected behavior as Power BI aggregates the same values by using an algorithm such as Sum, Count, etc.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
UPDATE:
Ok there has to be something wrong with d3.max
Because if i change from d3.max to d3.median, it shows me 16 on both (online and desktop), which is correct.
That means it actually has access to all values in the array.
So can it be a bug?
I also used map, but still, the max value in desktop-version shows 9...
.domain([0, d3.max(viewModel.dataPoints.map (function (d) { return <number>d.anzahlKostenstellen; }))]);
UPDATE2:
The problem is not d3.max.
I tried to solve it by only using a loop and check each value if its greater than max
let max = 0;
for (let i = 0, len = 100; i < len; i++) { if (((viewModel.dataPoints.map(function (d) { return <number>d.anzahlKostenstellen; }))[i]) > max) { max = ((viewModel.dataPoints.map(function (d) { return <number>d.anzahlKostenstellen; }))[0]); } }
let y = d3.scale.linear()
.range([ gHeight, 0 ])
.domain([0, max]);
But still i get 2 different values in powerbi desktop and online app...
From this point i really dont know why power bi is doing this. Does anybody have an idea?
- v-viig8 years agoCommunity Champion
Can you confirm that anzahlKostenstellen is always a number?
What version of d3 do you?
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
- az24518 years agoResolver I
anzahlKostenstellen is a PrimitiveValue but is used always as a <number>anzahlKostenstellen
I figured out what the problem was but still couldnt solve it.
In my table are two identical names.
For example if this is my original Table:
verantwortlicher gesamtKosten anzahlKostenstellen
Peter 200 3
Peter 500 5
Martin 100 1
Tom 400 9
It categorizes them together, which makes sense because my verantwortlicher is set to "Grouping" in my capabilities,json:
verantwortlicher gesamtKosten anzahlKostenstellen
Peter 200 3
Peter 500 5Martin 100 1
Tom 400 9
But i dont want PBI to group it together. How can i do this?
My capabilities.json
{ "dataRoles": [ { "displayName": "Verantwortlicher", "name": "verantwortlicher", "kind": "Grouping" // If i change this to "Measure", nothing works... }, { "displayName": "Gesamtkosten", "name": "gesamtKosten", "kind": "Measure" }, { "displayName": "Anzahl Kostenstellen", "name": "anzahlKostenstellen", "kind": "Measure" } ], "dataViewMappings": [ { "table": { "rows": { "select": [ { "for": { "in": "verantwortlicher" } }, { "for": { "in": "gesamtKosten" } }, { "for": { "in": "anzahlKostenstellen" } } ] } } } ], ...My Interface:
interface ChartDataPoint { verantwortlicher: string; gesamtKosten: PrimitiveValue; anzahlKostenstellen: PrimitiveValue; color: string; selectionId: ISelectionId; };My visualTransform:
function visualTransform(options: VisualUpdateOptions, host: IVisualHost): ChartViewModel { let dataViews = options.dataViews; let rows = dataViews[0].table.rows; let chartDataPoints: ChartDataPoint[] = []; for (let i = 0, len = rows.length; i < len; i++) { var row = rows[i]; chartDataPoints.push({ verantwortlicher: row[0] + '', gesamtKosten: <number>row[1], anzahlKostenstellen: <number>row[2], color: null, selectionId: null }); }
return {
dataPoints: chartDataPoints
};
}Thank you in advance!
- v-viig8 years agoCommunity Champion
This is expected behavior as Power BI aggregates the same values by using an algorithm such as Sum, Count, etc.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals