for just one KPI this is "relatively easy": You have to use IntervalMatch().
- Process your data in the script to have the correct values of that KPI for every UnitCD (say, that's a field
>>> KPIvalue <<<
- Load an Inline table with the intervals you want, using >>> IntervalMatch(KPIvalue) <<<
For several KPIs, you would have to use set analysis, specifying a lower_ bound and an upper_bound for both/ all of the KPIs in question and use a simple COUNT() as expression (y-axis) in your chart
=> You can, I guess, replace parts of your set_expression with fields/ variables that the user can select.