Forum Discussion

Pier8891's avatar
Pier8891
Frequent Visitor
1 year ago
Solved

Issue with Bar Chart Display When Switching Metrics in a Dynamic Slicer in Power BI

Problem Description I am using a slicer in Power BI to toggle between two different metrics in a bar chart and a donut chart. The dynamic measure I am using is the following:   DAX ChartValue = ...
  • DataNinja777's avatar
    1 year ago

    Hi Pier8891 ,

     

    The issue you are experiencing with the bar chart in Power BI occurs because the two metrics—Delay Quantities (a count-based measure) and AVG Delay Min (an average-based measure)—operate on drastically different scales. The number of delays per airport can be in the thousands, while the average delay time is typically in the tens or low hundreds. When switching between these metrics, the axis scale remains static, causing one measure to appear disproportionately large while the other becomes almost invisible.

    A possible solution is to enable a logarithmic scale for the Y-axis in the bar chart, which helps balance the differences between large and small values by adjusting the scale dynamically. If a logarithmic scale does not provide a satisfactory visualization, another approach is to use separate measures for each metric and then create two bar charts—one displaying Nums OF DELAYS and another displaying AVG MINS OF DELAYS—while using Bookmarks and the Selection Pane to toggle between them based on the slicer selection.

    Alternatively, if maintaining a single chart is preferred, normalization can be applied by scaling up the AVG Delay Min values to make them more visually comparable to Delay Quantities. This can be done by multiplying the average delay minutes by a factor such as 10, ensuring that it occupies a proportional space in the bar chart. The adjusted DAX formula for this approach is:

    ChartValue = 
        VAR SelectedOption = SELECTEDVALUE('Slicer 1'[Classification Delays], "Delay Minutes") 
        RETURN SWITCH(
            SelectedOption,
            "Delay Quantities", [Nums OF DELAYS] + 0,
            "AVG Delay Min", [AVG MINS OF DELAYS] * 10
        )
    

    This normalization method ensures that the bars remain visually distinguishable without distorting the actual data representation. If you would like guidance on implementing bookmarks for toggling between two separate charts, let me know, and I can provide step-by-step instructions.

     

    Best regards,