## Desktop

Frequent Visitor
Posts: 4
Registered: ‎11-05-2018

# 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

 A 40 2015 B 30 2015 C 10 2015 D 50 2015 A 30 2016 B 20 2016 C 60 2016 D 30 2016

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.

Accepted Solutions
Highlighted
New Contributor
Posts: 434
Registered: ‎08-25-2016

## Re: Display percentage in stacked column chart

Make this measure:

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

Hope this helps,

David

Super User
Posts: 2,142
Registered: ‎09-19-2016

## Re: Display percentage in stacked column chart

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

Proud to be a Datanaut!

New Contributor
Posts: 434
Registered: ‎08-25-2016

## Re: Display percentage in stacked column chart

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 )```

All Replies
Highlighted
New Contributor
Posts: 434
Registered: ‎08-25-2016

## Re: Display percentage in stacked column chart

Make this measure:

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

Hope this helps,

David

Super User
Posts: 2,142
Registered: ‎09-19-2016

## Re: Display percentage in stacked column chart

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

Proud to be a Datanaut!

Frequent Visitor
Posts: 4
Registered: ‎11-05-2018

## Re: Display percentage in stacked column chart

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

 A P1 TIMELY 11/1/2016 B P1 UNTIMELY 11/1/2016 C P2 TIMELY 11/1/2016 D P1 TIMELY 12/1/2016 E P1 UNTIMELY 1/1/2017 F P2 TIMELY 12/1/2016 G P1 TIMELY 11/1/2016 H P2 UNTIMELY 11/1/2016

DATE:

YEARMonthShort

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

viz:

New Contributor
Posts: 434
Registered: ‎08-25-2016

## Re: Display percentage in stacked column chart

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 )```

Frequent Visitor
Posts: 4
Registered: ‎11-05-2018

## Re: Display percentage in stacked column chart

As per the requirement, I need to sort those p1 timely,  p1 untimely, p2 timely and p2 untimely  in sorting order, but as the Power BI sorts automatically, it showing the visual in different sort order for the legend categories.
So I need to create measures to each one seperately as M_p1 timely,  M_p1 untimely, M_p2 timely and M_p2 untimely and added them in Value field. But now the DAX is not working even if i created a measure calculating the sum of all 4 measures and using that in the DAX you provided, Can you help me with that. Thanks in Advance