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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
lit2018pbi
Resolver II
Resolver II

Display percentage in stacked column chart

Hi,

 

I wanted to display percent of the overall set for the year as a tooltip in Power BI for a stacked column chart. Is there anyway to do it? 

 

Dataset: 

LabelValueYear

A402015
B302015
C102015
D502015
A302016
B202016
C602016
D302016

1.PNG

 

 

 

In the example above, I want add a tooltip for each Label - A,B,C,D individually to display the % for the specific year. Eg: For 2016, label A should display 30/140*100 = 21.42% as a tooltip and similarly rest of the labels too.

 

3 ACCEPTED SOLUTIONS
dedelman_clng
Community Champion
Community Champion

 Make this measure:

 

 

PctGT =
DIVIDE (
    SUM ( 'Table'[Value] ),
    CALCULATE ( SUM ( 'Table'[Value] ), ALL ( 'Table'[Label] ) ),
    0
)

 

Capture.PNG

 

Hope this helps,

David

View solution in original post

MFelix
Super User
Super User

Hi @lit2018pbi,

 

Add this measure to your tooltip and format as %, should work.

 

percentage =
DIVIDE (
    SUM ( Table1[Value] );
    (
        CALCULATE (
            SUM ( Table1[Value] );
            ALL (  Table1[Label] );
            FILTER ( ALL ( Table1[Year] ); Table1[Year] = MAX ( Table1[Year] ) )
        )
    )
)

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

Same basic code, but make a measure first like:

 

MyCount = CALCULATE( COUNTA ('Table3'[ID] ) )

Then everywhere you have " SUM ('Table1'[Value] ) " replace it with the measure above.

 

PctGTCnt =
DIVIDE ( [MyCount], 
         CALCULATE ( [MyCount], ALL ( 'Table3'[Value] ) ),
         0 )

Capture.PNG

View solution in original post

5 REPLIES 5
jgubler
Advocate III
Advocate III

If your bars are categotical instead of numerical:

 

Percent_mar =
DIVIDE (
COUNT(Query1[Gerneral Marital Status] ),
CALCULATE ( COUNT ( Query1[Gerneral Marital Status] ), ALL(Query1[TMS_filter])) ,
0
)

This is based off of @dedelman_clng 's answer above

MFelix
Super User
Super User

Hi @lit2018pbi,

 

Add this measure to your tooltip and format as %, should work.

 

percentage =
DIVIDE (
    SUM ( Table1[Value] );
    (
        CALCULATE (
            SUM ( Table1[Value] );
            ALL (  Table1[Label] );
            FILTER ( ALL ( Table1[Year] ); Table1[Year] = MAX ( Table1[Year] ) )
        )
    )
)

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



we have one more scenario like this which has date column (that we need to use on X-axis) is in another table and we dont have a numeric value in values. instead of that it showing categories, I have attached a picture for your reference. I wanted to display percent of that particular category individually  and considering that bucket itself as 100% as a tooltip in Power BI for a stacked column chart.

 

REF TABLE :

IDVALUEREF_DATE

AP1 TIMELY11/1/2016
BP1 UNTIMELY11/1/2016
CP2 TIMELY11/1/2016
DP1 TIMELY12/1/2016
EP1 UNTIMELY1/1/2017
FP2 TIMELY12/1/2016
GP1 TIMELY11/1/2016
HP2 UNTIMELY11/1/2016

 

DATE:

YEARMonthShort

2016Tuesday, November 01, 2016
2016Saturday, October 01, 2016
2016Thursday, September 01, 2016
2016Thursday, December 01, 2016
2017Sunday, January 01, 2017

 

viz:

 

2.PNG

Same basic code, but make a measure first like:

 

MyCount = CALCULATE( COUNTA ('Table3'[ID] ) )

Then everywhere you have " SUM ('Table1'[Value] ) " replace it with the measure above.

 

PctGTCnt =
DIVIDE ( [MyCount], 
         CALCULATE ( [MyCount], ALL ( 'Table3'[Value] ) ),
         0 )

Capture.PNG

dedelman_clng
Community Champion
Community Champion

 Make this measure:

 

 

PctGT =
DIVIDE (
    SUM ( 'Table'[Value] ),
    CALCULATE ( SUM ( 'Table'[Value] ), ALL ( 'Table'[Label] ) ),
    0
)

 

Capture.PNG

 

Hope this helps,

David

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.