Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
amelief
Frequent Visitor

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 :

1.JPG

 

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%.

2.JPG

 

May you help me ? 

 

Thanks a lot !

2 ACCEPTED SOLUTIONS
Stachu
Community Champion
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 )
    )

 



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

v-chuncz-msft
Community Support
Community Support

@amelief,

 

You may use measure below.

Measure =
DIVIDE (
    SUM ( Table1[value] ),
    CALCULATE ( SUM ( Table1[value] ), ALLSELECTED ( Table1[answer] ) )
)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-chuncz-msft
Community Support
Community Support

@amelief,

 

You may use measure below.

Measure =
DIVIDE (
    SUM ( Table1[value] ),
    CALCULATE ( SUM ( Table1[value] ), ALLSELECTED ( Table1[answer] ) )
)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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

Stachu
Community Champion
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 )
    )

 



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Stachu
Community Champion
Community Champion

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



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

I only put this params : 

3.JPG

 

Do you have an idea ?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.