Forum Discussion
Histogram with Dynamic Bins
- 3 years ago
Hi , tonysantangelo
According to your description, On your X axis, you want to put the minimum to maximum number of events where the deviceid exists, and then display the number of devices corresponding to the corresponding number on the Y axis.
Here are the steps you can refer to :
(1)My test data is the same as yours.(2)We can click "New Table " to create a table as x-axis value:
X-axis = var _max_count= MAXX( SUMMARIZE( 'Table' ,'Table'[DeviceId] , "count" , COUNT('Table'[EventId])) , [count]) return GENERATESERIES(1,_max_count,1)(3)Then we can create a measure :
Measure = var _t = SUMMARIZE( 'Table' ,'Table'[DeviceId] , "count" , COUNT('Table'[EventId])) var _max_value = MAXX(_t,[count]) var _min_value = MINX(_t , [count]) var _count = MAX('X-axis'[Value]) var _value = COUNTROWS( FILTER(_t, [count]=_count)) return IF(_count>=_min_value && _count<= _max_value ,_value+0, BLANK() )(4)Then we can put the fields we need on the visual and we can meet your need:
If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Replying to myself to add an additional requirement: My table also has a column for EventDate, and I need my histogram to respond to an EventDate slicer. Why is that relevant? I figured out that a solution to my original post would be to create a calculated table with a row per device and columns for number of events with each mode. Then I could use a field parameter for the user to switch between modes. However, this idea does not work with the additional date slicer because I can't feasibly create a column for each combination of mode + date range.