Forum Discussion

Aes's avatar
Aes
Frequent Visitor
3 years ago

Percentages in Tooltips

Hello very good,

 

I'm quite a newbie and can't solve a problem I encountered when trying to display percentages in the tooltip.

 

I have created a new page to display as tooltip where I have the net sales and % of sales.

 

I have calculated the percentage with the following DAX expression:

 

% Grandson = DIVIDE(
SUM('cfactf (2)'[Grandson]),
CALCULATESUM('cfactf (2)'[Grandson]), ALL('cfactf (2)'))
)

 

The percentages are correct, but my problem is that when on that page of the report, filter for a year, I receive the percentage of that year with respect to the overall total, when I want to receive the percentage with respect to the total of that year for which I am filtering.

 

That is, if I filter on that page for the year 2019 as in the example, I return the percentage of Television in the total of the year 2019 and not that I return the percentage of television in 2019 on the global total of all years.

 

And with all the years I mean any other filter that I can use on that same page, that is to say that the general total varies depending on any filter that I am going to use on that page therefore I am not worth a solution that is for a specific field.

 

I hope I explained myself well ðŸ˜‚

 

 

That is, what I can not solve is how to make the measurement so that the total of the net by which I divide to obtain the percentage, also varies depending on the filter I use on the page of the report in which I am.

 

Thank you very much, in advance.

 

PD:  With ALLSELECTED in the formula it is worse, it does not calculate the percentage by bars, it always shows me 100%, as you can see in the image

 

 

9 Replies

    • Aes's avatar
      Aes
      Frequent Visitor

      No, none of the solutions are valid...

       

      Sorry and thanks

      • mlsx4's avatar
        mlsx4
        Icon for Memorable Member rankMemorable Member

        Can you provide a piece of data (replace by "aaa" or things like this) ?

        It would be easier to find a solution with the data

  • Hi Aes ,

    According to your description, I create a sample and the ALLSELECTED function can work fine in my side. Not sure why it got 100% in your sample, you can only retain the second half CALCULATESUM('cfactf (2)'[Grandson]), ALLSELECTED('cfactf (2)')) to check what result does it return.

    Or try to modify the formula to:

    % Grandson =
    DIVIDE (
        SUM ( 'cfactf (2)'[Grandson] ),
        CALCULATE (
            SUM ( 'cfactf (2)'[Grandson] ),
            FILTER (
                ALL ( 'cfactf (2)' ),
                'cfactf (2)'[Year] IN VALUES ( 'cfactf (2)'[Year] )
            )
        )
    )
    

    If it still don't work, I attach my sample below, please download it and check, if the data structure is different with yours, please clarify it.

     

    Best regards,

    Community Support Team_yanjiang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

    • Aes's avatar
      Aes
      Frequent Visitor

      Hi v-yanjiang-msft,

       

      No, it didn't work for me, I still have the same problem.

      I attach a capture of my data

      I want that when selecting the cursor when I calculate the percentage that I show in tooltip, it varies depending on the filters that I have selected in the segmenters.

      I give an example:

      1. No selection:
        TV = €700 ->70%
        Radio = €300 ->30%
      2. I select 2019:
        -I want it to appear:
         TV = €400 ->80% 
         Radio = €100 ->20%
        -However it appears:
         TV=€400 ->40%
         Radius €100 ->10%

      I want to select year, or client or country or any other filter that I want to use, I don't need a formula that only works for a single field

       

      A lot of thanks

    • Aes's avatar
      Aes
      Frequent Visitor

      An answer that only works for me with a year is not valid

  • Hi Aes ,

    Has your problem been resolved? If so, please kindly accept the helpful reply as solution, then we'll close the thread, other people who has the similar problem will benefit here.

     

    Best regards,

    Community Support Team_yanjiang