I’m trying to represent some continuous data via binning. Continuous weighting data of an area should be binned as: VeryHigh, High, Low, VeryLow. The weighting values are based on an interaction between certain Types of events grouped by an Area and so can change depending on the Type selected by the report user.
I have included some sample data below and an outline of what’s been done so far.
Start with five sets of area data (A-E). Within each is one or more incident Types. Each incident has a Weighting and the number of times (Count) it occurs within the Area.
Add a calculated column CC_ALL_WGT (weighting * count)
Create a measure:
M_WGT = DIVIDE(SUM(sample_data[CC_ALL_WGT]), SUM(sample_data[4_count]))
This makes sense once grouped by Area and we can see that the Area gets an overall Weighting Score
This can be altered by slicing the data based on which Type of incident we wish to inspect:
We can also set up additional measures to get the Min; Max; Median from the Measure based on the Type selection:
M_MIN_M_WGT = IF(
countrows(values(sample_data[1_area])) = 1,
sample_data[M_WGT],
MINX(
values(sample_data[1_area]),
sample_data[M_WGT]
)
)
Which change as expected when a Slicer selection is made
Also set up a measure to determine the Mid-Point between the Minimum and the Median and Mid-Point between the Maximum and the Median
M_MidMinMed =
sample_data[M_MED_M_WGT] - ((sample_data[M_MED_M_WGT] - sample_data[M_MIN_M_WGT]) / 2)
What I would like to do with these values is create a banding based on the following:
VeryLow: (Minimum to MinMed mid-point) Low: (MinMed to Median) High: (Median to MedMax mid-point) VeryHigh: (MedMax to Maximum)
So based on the following selection
The bins would be set up as follows
- VeryLow (0.59 to 0.76)
- Low (0.76 to 0.93)
- High (0.93 to 1.01)
- VeryHigh (1.01 to 1.1)
Area A would be in Bin 4 (VeryHigh); Area B in Bin 2 (Low); Area C in Bin 1 (VeryLow); Area D in Bin 2 (Low); Area E in Bin 4 (VeryHigh)
If select specific Types to review (via the slicer) the bins would be set up as follows:
- VeryLow (0.35 to 0.61)
- Low (0.61 to 0.88)
- High (0.88 to 1.06)
- VeryHigh (1.06 to 1.24)
So checking M_WGT (with types specified in the slicer):
Area A would be in Bin 4 (VeryHigh); Area B in Bin 2 (Low); Area C in Bin 1 (VeryLow); Area D in Bin 1 (VeryLow); Area E in Bin 4 (High)
NOTE - The change in bin classification for Area D from Low to VeryLow
This is where I get stuck. This post specifies how to apply a static bin range: https://community.powerbi.com/t5/Desktop/Histogram-User-defined-bin-size/m-p/69854#M28961 but I’ve not been able to do this using dynamic or changing values (the Min; Max; Media; Midpoint) depending on selection.
The closest I’ve managed to apply is as follows:
Range =
VAR temp =
CALCULATE ( sample_data[M_WGT] )
RETURN
IF (
temp < 0.76,
"1_VeryLow",
IF (
AND ( temp > 0.76, temp <= 0.93 ),
"2_Low",
IF (
AND ( temp > 0.93, temp <= 1.01 ),
"3_High",
"4_VeryHigh"
)
)
)
Which permitted the following:
While I can then associate the Bins with a visual there are a number of things wrong with it. Firstly binning is occurring at the TYPE level not the AREA level. Secondly I’m manually setting the range values.
When I say Type levels what I mean is that they’re being binned at this level:
Whereas what I would like the histogram to be representing are the M_WGT values at the Area level.
If I slice by Area A only the problem is easier to see:
What would I like is for there to be one representation of Area A in the histogram (the bin for 1.10), not the three currently being shown (for each Type 1.9; 1; 0.35)
Hopefully I’ve managed to convey the problem and requirement.
Appreciate any advice or insight.
EDIT: Link to Report + Data source is here: https://www.dropbox.com/sh/oganwruacdzgtzm/AABlggr3-xqdMvPjuR9EyrMaa?dl=0