Forum Discussion

pp_123's avatar
pp_123
New Member
1 year ago
Solved

issue with dynamic formatting

Hi I am facing an issue with dynamic formatting. The dynamic formatting code is shown below: var _currentvalue = SUM('Sales By Product Details'[Sale]) var _numberformat =  SWITCH (     TRU...
  • burakkaragoz's avatar
    burakkaragoz
    1 year ago

    Thanks for confirming those steps — sounds like you're doing everything right on the surface. Since the dynamic format still isn't applying in the visual, here are a few deeper checks you can try:

    1. Double-check the measure assignment

    Make sure the dynamic format string is assigned to the same measure that’s being used in the visual. Sometimes a copy or renamed version of the measure is used in the chart, and the formatting doesn’t carry over.

    2. Use FORMAT function as a fallback

    If the visual still ignores the format string, you can try formatting the value manually in a new measure:

    Formatted Value = 
    VAR _value = [YourMeasure]
    VAR _format = 
        SWITCH (
            TRUE(),
            _value < 1E3, "#,0",
            _value < 1E6, "#,0.0,K",
            _value < 1E9, "#,0.0,,M",
            "#,0,,B"
        )
    RETURN FORMAT(_value, _format)

    Then use this Formatted Value in a card or table visual to test if the formatting logic works as expected.

    ⚠️Note: This won't work in bar/column charts directly since they expect numeric values — but it's a good way to debug the format logic.

    3. Try a clean test visual

    Sometimes visuals cache formatting. Try:

    • Creating a new bar chart from scratch.
    • Drag the measure again.
    • Set display units to None.
    • Recheck if the dynamic format kicks in.

    4. Known limitation

    Dynamic format strings don’t always apply to data labels in visuals like bar/column charts — especially if the visual is using auto-scaling or display units. In that case, it might be a current limitation of the visual engine.
    translation and formatting supported by AI