Forum Discussion
Dynamic banding in Stacked Column Chart via user input threshold values as comma-separated list
We have a requirement where end-users need to dynamically split/segment a Stacked Column Chart based on custom numeric thresholds provided at runtime.
The user wants to enter threshold values as a comma-separated list in an input control. Based on these inputs, the chart should dynamically calculate and render bands for the stacked bars and legend.
Sample Data:
Base Table: OrdersFact
Following is the description of columns that will be required from this table
- OrderId - Integer - Unique identifier for each order
- OrderDate - Date - Date of the transaction (X-Axis)
- Price - Decimal - Total price of all products in that order. This is to be used for dynamic banding
Visual Mapping:
We are looking to implement a 100% Stacked Column Chart where:
- X-Axis: OrdersFact[OrderDate] (grouped by Year or Month)
Y-Axis: COUNT(OrdersFact[OrderId]) (expressed as 100% relative percentage stacked composition)
Legend (Bands): Segmented by OrdersFact[Price] into dynamic bands.
Expected Dynamic Behavior:
- Users specify price thresholds in a comma-separated list form: `86, 111`.
- The visual segments the total order count into N+1 dynamic price ranges (Here, N = 2):
- Band 1: min < 86
- Band 2: 87 - 110
- Band 3: 111 - max
- Bars dynamically recalculate and re-stack whenever threshold parameters change.
The objective is to allow end-users to provide runtime threshold inputs without hardcoding or capping the number of available dynamic thresholds. Entering N comma-separated dynamic values (e.g., 86, 111) should dynamically generate N+1 stacked bands on the chart (e.g., Band 1: < 86, Band 2: 86 - 111, Band 3: > 111).
Core Questions:
- Since the `Legend` bucket in a Power BI Stacked Column Chart requires a static column from the data model, is there any supported DAX pattern that allows:
- Parsing a dynamic text string of comma-separated numbers into individual thresholds.
- Dynamically assigning data points into a dynamic number of bands without a fixed legend column?
- If direct implementation on the standard Stacked Column Chart isn't supported due to Legend bucket constraints, what would be the best recommended alternative design pattern or workaround to achieve similar dynamic behavior?
Approaches Explored:
We have evaluated standard Power BI methods, but each carries significant architectural limitations for this specific setup:
1. Numeric Range (What-If) Parameters:
Limitation: Requires creating a fixed, finite number of dynamic parameter slicers in advance (e.g., T1, T2, T3). This caps the dynamic capabilities and does not scale if a user needs to input 5 or 10 dynamic boundaries at runtime.
2. Predefined Threshold Combinations:
Limitation: Requires hardcoding combination mapping tables into the data model. It removes true ad-hoc runtime flexibility for the user.
Since these standard approaches have trade-offs, I am looking for alternative architectural patterns or workarounds that can achieve this functionality.
Any guidance or sample approaches would be greatly appreciated!
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.
7 Replies
- Prince0011
Solution Sage
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
💡 Helpful? Give a Kudos 👍 — keep the community growing.
✅ Solved your issue? Mark this as the Accepted Solution ✔️
Best regards, Prince Singh | Data Science & Microsoft Fabric Enthusiast
- danextian
Super User
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.
- ryan_mayu
Super User
I am not sure if wen can do this by inputting the data. Maybe we can select or choose the data to set up the scope. could you pls provide some sample data and expected output
- SanketMendheNew Member
I have added the sample data format along with the approaches that have been considered in the original post. Please check and let me know if there are any alternative architectural patterns or workarounds that can achieve this functionality.
- SanketMendheNew Member
Sure, here is the sample data.
Base Table: OrdersFact
OrderID OrderDate Price 1001 Jan 2026 45.00 1002 Jan 2026 95.00 1003 Jan 2026 120.00 1004 Feb 2026 60.00 1005 Feb 2026 100.00 1006 Feb 2026 150.00
Following is the description for columns in above table:Field Name Data Type Description OrderId Integer Unique identifier for each order OrderDate Date Date of the transaction (X-Axis) Price Decimal Totoal price of all products in that order. This is to be used for dynamic banding
Visual Mapping:We are looking to implement a 100% Stacked Column Chart where:
X-Axis: OrdersFact[OrderDate] (grouped by Year or Month)
Y-Axis: COUNT(OrdersFact[OrderId]) (expressed as 100% relative percentage stacked composition)
Legend (Bands): Segmented by OrdersFact[Price] into dynamic bands.
Expected Dynamic Behavior:
Users specify price thresholds in a comma-separated list form: `86, 111`
The visual segments the total order count into N+1 dynamic price ranges (Here, N = 2):
Band 1: min < 86
Band 2: 87 - 110
Band 3: 111 - max
Bars dynamically recalculate and re-stack whenever threshold parameters change.
The objective is to allow end-users to provide runtime threshold inputs without hardcoding or capping the number of available dynamic thresholds. Entering N comma-separated dynamic values (e.g., 86, 111) should dynamically generate N+1 stacked bands on the chart (e.g., Band 1: < 86, Band 2: 86 - 111, Band 3: > 111).
Expected Visual:
Approaches Explored:
We have evaluated standard Power BI methods, but each carries significant architectural limitations for this specific setup:
1. Numeric Range (What-If) Parameters:
Limitation: Requires creating a fixed, finite number of dynamic parameter slicers in advance (e.g., T1, T2, T3). This caps the dynamic capabilities and does not scale if a user needs to input 5 or 10 dynamic boundaries at runtime.
2. Predefined Threshold Combinations:
Limitation: Requires hardcoding combination mapping tables into the data model. It removes true ad-hoc runtime flexibility for the user.
Since these standard approaches have trade-offs, I am looking for alternative architectural patterns or workarounds that can achieve this functionality.
- v-kathullac
Community Support
Thankyou danextian , Prince0011 , ryan_mayu for Addressing the issue.
Hi SanketMendhe ,
Thank you for reaching out to Microsoft Fabric Community Forum,
As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
Regards,
Chaithanya
- v-kathullac
Community Support
Hi @SanketMendhe ,
Thank you for reaching out to Microsoft Fabric Community Forum,
As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
Regards,
Chaithanya