Forum Discussion
Dynamic banding in Stacked Column Chart via user input threshold values as comma-separated list
- 1 month ago
Hi SanketMendhe
Unless you can write back to the sourc (using Translytical Taskflows with a Fabric capacity or a third-party service) users can't simply enter an arbitrary value and expect that value to be used directly in visuals.
Also, measures don't have row context, so they can't be used as a legend. A common workaround is to use a disconnected table that the measures can reference. It is possible, but the logic can get pretty complex.
x
The example below demonstrates one way to achieve this.
Please see the attached sample pbix.
Unfortunately, this isn't supported by the native Power BI Stacked Column Chart due to how the visual engine works.
The key limitation is that the Legend field must be bound to a physical column in the semantic model. Power BI determines the legend categories before DAX measures are evaluated, so a measure cannot dynamically create a varying number of legend categories at runtime.
Specifically:
❌ DAX cannot parse a user-entered comma-separated string and dynamically create N+1 legend categories.
❌ Measures cannot return a dynamic set of categories for the Legend bucket.
❌ Field Parameters can switch between existing fields, but they cannot generate new categories dynamically.
Possible alternatives
1. Fixed maximum number of thresholds (Most practical)
Create a predefined number of threshold parameters (e.g., 5 or 10) and corresponding band logic. While users won't have unlimited thresholds, this approach works well for most business scenarios.
2. Use Deneb (Recommended for full flexibility)
If truly dynamic banding is required, Deneb (Vega-Lite) is probably the best option.
With Deneb, you can:
Accept a user-defined threshold table (instead of a comma-separated text string).
Dynamically calculate the band for each row.
Render a stacked chart without relying on the native Legend limitations.
Support an arbitrary number of bands, limited only by the data provided.
3. Store thresholds in a table instead of a text string
Instead of entering:
86,111,150,250
allow users to maintain a Thresholds table (via Power Apps, Fabric, SQL, SharePoint, Excel, etc.):
Threshold
| 86 |
| 111 |
| 150 |
| 250 |
Your ETL or Power Query process can then:
Sort the thresholds.
Generate the ranges.
Assign each order to a band before it reaches the visual.
This is much more maintainable than parsing free-form text.
4. Perform the banding upstream
If the thresholds need to change frequently, consider moving the logic to:
Fabric Notebook
Dataflow Gen2
SQL stored procedure
Azure Function/API
These technologies can parse the threshold list, generate dynamic bands, and return a dataset that Power BI can visualize.
Recommendation
If the requirement is true runtime, unlimited dynamic thresholds entered by the user, there isn't a supported DAX-only solution with the native stacked column chart.
The most scalable approaches are:
Deneb for custom visualization and dynamic encoding.
Threshold table + ETL/Dataflow for enterprise-grade implementations.
I'd be interested to hear if anyone has implemented a similar requirement using Deneb, Charticulator, or another custom visual while maintaining good report performance.
For more information:
Deneb custom visual: https://deneb-viz.github.io/
Field Parameters in Power BI: https://learn.microsoft.com/power-bi/create-reports/power-bi-field-parameters
What-if parameters: https://learn.microsoft.com/power-bi/transform-model/desktop-what-if