Forum Discussion

jasemilly's avatar
jasemilly
Icon for Helper III rankHelper III
10 months ago
Solved

Custom data label on area chart not showing value. Measure displays correctly on a table

Hi

I am trying to use the custom data label on an area chart to provide infomation percentage change, but it doesn't display at all.

I can put the measure in a table, it always displays correctly

when I hard code the value into the variable it works, is it possible to force the nuber of decimal places used in the dax code?

this works

var _growth = 
 
     divide( 0.078 , 0.086) 

var _rtrn =  

     FORMAT( _growth, "0.0% ▲;0.0% ▼;" )     

return

_rtrn

 

this doesn't display in the custom data label but does display correctly in the table, it display 7.89% which is correct.

var _growth = 
              divide( _AgentScoreDelta , _AgentPreviousScore) 
var _rtrn =  

              FORMAT( _growth, "0.0% ▲;0.0% ▼;" )     
return

_rtrn

 

  • Anonymous's avatar
    Anonymous
    10 months ago

    Hi jasemilly ,

    Thank you for your follow-up and for pinpointing that the issue was due to missing dates in the fact table. If the dataset doesn’t cover a continuous date range, visuals like the area chart may not render labels for dates with no data, even though the measure works correctly in a table.

    To fix this, create a separate Date table, mark it as a Date Table in your model, and link it to your fact table. Using functions like ISINSCOPE() or COALESCE() can help ensure your measure returns values for all dates, allowing labels to display consistently.

    Glad to see you and tayloramy have already identified the root cause. If you can provide an updated PBIX via a public link, the community can review and confirm your solution resolves the visual issue.

     

    Thank you.

     

16 Replies

  • Hi jasemilly

    I was able to get this to work bu seperating out the growth% math to a different measure. 

     

    // Base measures
    Agent Previous Score = MAX ( Scores[Previous] )
    Agent Current Score  = MAX ( Scores[Current] )
    Agent Score Delta    = [Agent Current Score] - [Agent Previous Score]
    
    // Growth as a numeric measure (good for other visuals)
    Growth % = DIVIDE ( [Agent Score Delta], [Agent Previous Score] )
    
    // Text label for custom data label (forces a string even when numeric is BLANK)
    Growth Label (text) =
    VAR g = [Growth %]
    RETURN
    IF (
        NOT ISBLANK ( g ),
        FORMAT ( g, "0.0%" ) & " " & IF ( g >= 0, "▲", "▼" ),
        ""     // empty string (not BLANK) so the visual will still try to draw it
    )

     

    Here is a working file example

    https://drive.google.com/file/d/1qs2FnBAQr68TQhXMlKvU6zr9gWM1AqyG/view?usp=sharing

     

    If you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, mark this post as the solution.

    • jasemilly's avatar
      jasemilly
      Icon for Helper III rankHelper III

      Hi Tayloramy

       

      I had tried splitting into sperate measures earlier and tried your approach as well.  This didn't work, I believe it should work.  I am at a loss to why it doesn't.


      Thanks for replying

      • tayloramy's avatar
        tayloramy
        Icon for Super User rankSuper User

        Hi jasemilly

         

        Is what I achieved in the file I linked not your intended goal? 

        If not, I may have misunderstood what you're needing.  

    • jasemilly's avatar
      jasemilly
      Icon for Helper III rankHelper III

      I have realised this is an issue with row filtering and my fact table doesn't have an entry for every day.

      • tayloramy's avatar
        tayloramy
        Icon for Super User rankSuper User

        Hi jasemilly

         

        Glad you found the issue! 

        Let us know if you need anything else. 

         

        If you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, mark this post as the solution. 

  • Hi jasemilly ,

     

    Yes.  It is possible to do what you are trying to do with the following steps:

    • In the stacked area chart, go to Visualization pane → Visual tab → Data label → turn it On
    • go to Values section and put a measure below in the Field box:
    Growth % Label (text) = 
    VAR g = [Growth % (numeric, safe)]
    RETURN
    IF (
        ISINSCOPE ( 'Date'[Date] ) && NOT ISBLANK ( g ),
        FORMAT ( g, "0.0%" ) & IF ( g >= 0, " ▲", " ▼" ),
        BLANK ()
    )

    The resultant output is as shown below, and I hope that this meets your requirement.

    I attach an example pbix file for your reference.

     

    Best regards,

     

    • jasemilly's avatar
      jasemilly
      Icon for Helper III rankHelper III

      Thanks for taking a look but I have done this already everything appears fine when I hard code it.

  • Hi jasemilly

     

    That is a private link, can you open it up so anyone with the link can view it so we can download it?  

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi jasemilly ,

    Thank you for your follow-up and for pinpointing that the issue was due to missing dates in the fact table. If the dataset doesn’t cover a continuous date range, visuals like the area chart may not render labels for dates with no data, even though the measure works correctly in a table.

    To fix this, create a separate Date table, mark it as a Date Table in your model, and link it to your fact table. Using functions like ISINSCOPE() or COALESCE() can help ensure your measure returns values for all dates, allowing labels to display consistently.

    Glad to see you and tayloramy have already identified the root cause. If you can provide an updated PBIX via a public link, the community can review and confirm your solution resolves the visual issue.

     

    Thank you.

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi jasemilly ,

      I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We’re always here to support you

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi jasemilly ,
        I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.