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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
OscLar
Helper I
Helper I

Switching the binning of a histogram

Hi,

 

New day, new question. I've seen that there are questions about binning a histogram flying around the forum but I haven't found an answer to my question. If it already exists, I'm sorry for dubble posting the question...

 

I've written a code to create a calculated column for the "binID" for the data value to be added in a histogram, and it looks like this:

 

xAxis = 
var binWidth = 50
var inData = 'Table'[Column]
var rest = MOD(inData; binWidth)
var binID = inData - rest + (binWidth/2) 
return binID

 

Then I can plot my data as the value and my xAxis as the axis of the histogram. This alows me to easily change the binning of the histogram by just changing the value of the binWidth variable.

 

Now, I'm wondering, is there an easier or better way of doing this?? That is an easier way of creating a histogram in which I can change the bin width back and foth.

 

I know this limits the binning to fixed width, but this is what I need so variable bin width does not need to be considered.

 

Cheers,

 

OscLar

4 REPLIES 4
Anonymous
Not applicable

HI @OscLar,

 

>>Then I can plot my data as the value and my xAxis as the axis of the histogram. This alows me to easily change the binning of the histogram by just changing the value of the binWidth variable.

If you mean control axis range, you can manually setting it at format tab x-axis/y-axis.

1.PNG

 

>>Now, I'm wondering, is there an easier or better way of doing this?? That is an easier way of creating a histogram in which I can change the bin width back and foth.

Maybe you can try to use other column as the bin for calculate.  Notice, if you want to create dynamic calculate column who changed based on slicer/filter, current power bi not support dynamic column/table.

 

Regards,

Xiaoxin Sheng

Hi @Anonymous,

To answer your frirst question; no, it was not the range of the x-axis I was refering to.  This function I was awar of, but thanks anyway 🙂

 

Secondly, Not sure I understand the first part of your statement. I am already creating a calculated column to basicalley create a rounded off number to be used as an axis.

 

However, after writing the original post I realised that this only works to plot the values from one column. There's an (now for me obvious) error in my logic when trying to plot two different data columns using the same x-axis. Since you have to create an axis column for each data column to be plotted and thus cant't plot the two data columns in the same histogram.

 

It's most likely my lack of deeper knowledge of PBI and/or DAX which has put me in this spot, so if anyone has any suggestions I'd be very happy.

 

Cheers,

 

OscLar

 

 

Anonymous
Not applicable

HI @OscLar,

 

 

I'd like to suggest you use r script to draw histogram, it may more suitable to draw complex graph.

In addition, you can also contact to custom visual team to get more support.(I think you requirement is hard to achieve on current histogram visual)

 

Regards,

Xiaoxin Sheng

Hi,

 

Ok, thanks for the info. I'll try to contact them.

 

Cheers,

 

OscLar

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors