Forum Discussion

vipett's avatar
vipett
Helper III
8 months ago
Solved

Wrong number formatting data label when highlighted

I have a simple graph with a measure "On time" which is formatted as %, normally it looks fine

 

But if I highlight a category or country or anything it loses its data formatting: 

 

Any idea what I could do to correct this?

 

  • vipett's avatar
    vipett
    8 months ago

    It sounds reasonable, but still doesn't work..

    Luckily this was not in a Production file, but just connected to a test environment and in the production environment it worked without any workarounds..

14 Replies

  • Hii vipett 

     

    This happens because when a visual is highlighted, Power BI internally creates a second version of your measure (the “highlighted value”), and that temporary value does not keep the original formatting from the model. Since formatting is lost during highlight, the only fix is to explicitly format the measure using FORMAT() for the data label, like:

    OnTime_Display =
    FORMAT([On time], "0.0%")

    Use this field only for labels/titles (not calculations). This forces the percent format even when highlighted and resolves the issue.

    • vipett's avatar
      vipett
      Helper III

      Thanks, but even when I added that measure and put it in the Data labels tab as values, but I still get the same result

       

       

  • v-venuppu's avatar
    v-venuppu
    Community Support

    Hi vipett ,

    Thank you for reaching out to Microsoft Fabric Community.

    Thank you GeraldGEmerick ChielFaber rohit1991 for the prompt response.

    The percentage formatting disappears during highlighting because Power BI creates an internal “highlighted value” that loses the measure’s formatting metadata in your PBIX.This is why the problem does not happen in a new file.Keep your original numeric measure, but create a display-only wrapper measure for data labels:

    On-time % (orders) – Display =
    VAR v = [On-time % (orders)]
    RETURN FORMAT(v, "0.0%")

    Then:

    Use [On-time % (orders)] for the visual values.

    Use On-time % (orders) – Display only in Data labels.

    This forces Power BI to show the correct % formatting even when the visual is highlighted.

     If formatting still breaks:

    Your PBIX has corrupted formatting metadata - recreate the model in a new PBIX (this is why your test file works correctly).

    • vipett's avatar
      vipett
      Helper III

      It sounds reasonable, but still doesn't work..

      Luckily this was not in a Production file, but just connected to a test environment and in the production environment it worked without any workarounds..

      • v-venuppu's avatar
        v-venuppu
        Community Support

        Hi vipett ,

        Thank you for confirming that it got worked from your end.If any of the responses guided you in solving the issue,I would suggest to accept that response as a solution.So that other community members with similar problems can find a solution faster.

  • vipett I'm not able to replicate this behavior when I set a column to be "%" formatted in the Formatting section of the Column tools tab in the ribbon. How are you doing your formatting?

  • Could you show us the measures your using? 

     

    Try creating a measure with an assigned format:

    OnTime % (Formatted) :=
    VAR v = [OnTime %]
    RETURN FORMAT(v, "0.0%")

    • vipett's avatar
      vipett
      Helper III
      On-time % (orders) =
      VAR OrdersScope =
          SUMMARIZE(
              'Purchase Order Line',
              'Purchase Order Line'[DIM_COMPANY_KEY],
              'Purchase Order Line'[DIM_SITE_KEY],
              'Purchase Order Line'[Order No]
          )
      VAR OrdersEval =
          ADDCOLUMNS(
              OrdersScope,
              "__Eligible",
                  CALCULATE(
                      COUNTROWS('Purchase Order Line'),
                      ALLEXCEPT(
                          'Purchase Order Line',
                          'Purchase Order Line'[DIM_COMPANY_KEY],
                          'Purchase Order Line'[DIM_SITE_KEY],
                          'Purchase Order Line'[Order No]
                      ),
                      NOT ISBLANK('Purchase Order Line'[DatediffPromied])
                  ),
              "__Late",
                  CALCULATE(
                      COUNTROWS('Purchase Order Line'),
                      ALLEXCEPT(
                          'Purchase Order Line',
                          'Purchase Order Line'[DIM_COMPANY_KEY],
                          'Purchase Order Line'[DIM_SITE_KEY],
                          'Purchase Order Line'[Order No]
                      ),
                      NOT ISBLANK('Purchase Order Line'[DatediffPromied])
                          && 'Purchase Order Line'[DatediffPromied] >= 1
                  )
          )
      VAR TotalEligibleOrders =
          COUNTROWS( FILTER(OrdersEval, [__Eligible] > 0 ) )
      VAR OnTimeOrders =
          COUNTROWS( FILTER(OrdersEval, [__Eligible] > 0 && [__Late] = 0 ) )
      RETURN IF( TotalEligibleOrders = 0, BLANK(), DIVIDE(OnTimeOrders, TotalEligibleOrders) )
  • v-venuppu's avatar
    v-venuppu
    Community Support

    Hi vipett ,

    I wanted to check if you had the opportunity to review the information provided and resolve the issue..?Please let us know if you need any further assistance.We are happy to help.

    Thank you.