Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
az2451
Resolver I
Resolver I

Possible Bug in d3.scaling | EDIT: How to void grouping/categorizing data

Hi there,

 

Ive just created two simple y and x-axes

 

The x-axis works fine in both, powerbi online and desktop version.

But if you take a look to the y-axis, the scaling fails however in power bi desktop. And this is something i dont understand why because i didnt do anything much different than for the x-axis. 

 

To create the domains im using the min/max-functions from the d3 library.

  

Possible bug?

 

  

For any solution i would be very thankful!

 

1 ACCEPTED SOLUTION
v-viig
Community Champion
Community 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

pbicvsupport@microsoft.com

View solution in original post

5 REPLIES 5
az2451
Resolver I
Resolver I

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-viig
Community Champion
Community 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

pbicvsupport@microsoft.com

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                              5

Martin                      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-viig
Community Champion
Community 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

pbicvsupport@microsoft.com

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.