Forum Discussion

SanketMendhe's avatar
SanketMendhe
New Member
1 month ago
Solved

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:

  1. 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?
  2. 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

  • 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:

    💡 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

  • 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.

  • 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

    • SanketMendhe's avatar
      SanketMendhe
      New 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.

  • Sure, here is the sample data.

     

    Base Table: OrdersFact

    OrderIDOrderDatePrice
    1001Jan 202645.00
    1002Jan 202695.00
    1003Jan 2026120.00
    1004Feb 202660.00
    1005Feb 2026100.00
    1006Feb 2026150.00


    Following is the description for columns in above table:

    Field NameData TypeDescription
    OrderIdIntegerUnique identifier for each order
    OrderDateDateDate of the transaction (X-Axis)
    PriceDecimalTotoal 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):

      1. Band 1: min < 86

      2. Band 2:  87 - 110

      3. 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's avatar
    v-kathullac
    Icon for Community Support rankCommunity 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's avatar
    v-kathullac
    Icon for Community Support rankCommunity 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