Forum Discussion

amelief's avatar
amelief
Frequent Visitor
7 years ago
Solved

Percent, Legend and Histogram

Hi Everyone,

 

I'm trying to make a histogram with a year-by-year comparison of answers 1 to 5.
it gives me this :

 

My question is about the total : I don't kown how to have 100% by year (legend).

My problem is that the total per year is not 100%. It's the sum of all my bars that is 100%.

 

May you help me ? 

 

Thanks a lot !

  • I don;t think it;s possible with just UI, you will need to:
    1) create a new measure (press 'New Measure' in Modelling in the ribbon)
    2) syntax should be something like this - you will need to adjust the blue parts

    this code assumes that Annee is a numeric field, not text

     

    % of total =
    VAR varYear =
        MAX ( Table[Annee] )
    RETURN
        DIVIDE (
            SUM ( Table[Nombre de Quel...] ),
            CALCULATE ( SUM ( Table[Nombre de Quel...] ), Table[Annee] = varYear )
        )

     

  • amelief,

     

    You may use measure below.

    Measure =
    DIVIDE (
        SUM ( Table1[value] ),
        CALCULATE ( SUM ( Table1[value] ), ALLSELECTED ( Table1[answer] ) )
    )
    

5 Replies

  • Stachu's avatar
    Stachu
    Community Champion

    what's the syntax for the [%TG...] measure?

    • amelief's avatar
      amelief
      Frequent Visitor

      I only put this params : 

       

      Do you have an idea ?

  • Stachu's avatar
    Stachu
    Community Champion

    I don;t think it;s possible with just UI, you will need to:
    1) create a new measure (press 'New Measure' in Modelling in the ribbon)
    2) syntax should be something like this - you will need to adjust the blue parts

    this code assumes that Annee is a numeric field, not text

     

    % of total =
    VAR varYear =
        MAX ( Table[Annee] )
    RETURN
        DIVIDE (
            SUM ( Table[Nombre de Quel...] ),
            CALCULATE ( SUM ( Table[Nombre de Quel...] ), Table[Annee] = varYear )
        )

     

  • v-chuncz-msft's avatar
    v-chuncz-msft
    Community Support

    amelief,

     

    You may use measure below.

    Measure =
    DIVIDE (
        SUM ( Table1[value] ),
        CALCULATE ( SUM ( Table1[value] ), ALLSELECTED ( Table1[answer] ) )
    )
    
    • amelief's avatar
      amelief
      Frequent Visitor

      Thank you ! Sorry, I did'nt saw your answer before !