Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Transforming integer to percentage in pie chart

Hello everyone,

I am trying to convert number to percentage in a pie chart, which i have 3 expressions:

sum([Baby Boomers])

sum(X)

sum(Y)

In the Expression tab, when i select the relative box, all results are 100%:

pie.jpg

If i unselect the relative box and set the percentage in the Number tab, the results are wrong:

pie.jpg

Below is the chart with the original numbers:

pie.jpg

How can i convert the numbers above to the correct percentage?

Regards

1 Solution

Accepted Solutions
MarcoWedel

Hi,

one solution could be either:

QlikCommunity_Thread_193151_Pic1.JPG

QlikCommunity_Thread_193151_Pic2.JPG

(Rangesum() instead of just adding the fields for proper null-value results)

QlikCommunity_Thread_193151_Pic5.JPG

or (without changing your data model) using a calculated dimension and a single expression to be able to use the "relative" option for expressions like already suggested by swuehl‌ (although I think his CrossTable solution results in the better data model for your requirements):

QlikCommunity_Thread_193151_Pic3.JPG

QlikCommunity_Thread_193151_Pic4.JPG

hope this helps

regards

Marco

View solution in original post

12 Replies
Mark_Little
Luminary
Luminary

Hi

I would look at something like

sum([Baby Boomers])  / (sum([Baby Boomers]) + sum(X) + sum(Y))

sum(X)  / (sum([Baby Boomers]) + sum(X) + sum(Y))

sum(Y)  / (sum([Baby Boomers]) + sum(X) + sum(Y))


Mark

buzzy996
Master II
Master II

can u share sample .qvw?

Not applicable
Author

Thanks for your response Mark.

I have other pie chart, with different expressions:

sum({<[Generations]={"Regional"}>}[Baby Boomers])

sum({<[Generations]={"Regional"}>}X)

sum({<[Generations]={"Regional"}>}Y)

I am just selecting values from Regional for each Generation.

How it should be the expression to calculate the percentage in that case?

Best regards,


Marcio_Campestrini
Specialist
Specialist

Rodrigo

You can calculate it or simply mark the option "Relative" in expressions tab.

2015-11-26 14_14_35-QlikView x64 - [QV1].png

Márcio Rodrigo Campestrini
Not applicable
Author

Hi Márcio,

When i select the option Relative in expressions tab, the result is wrong, all values is 100% as i mentioned before:

pie.jpg

settu_periasamy
Master III
Master III

Hi Rodrigo,

May be try this expression..

sum({<[Generations]={"Regional"}>}[Baby Boomers])/sum({<[Generations]={"Regional"}>} TOTAL [Baby Boomers])

sum({<[Generations]={"Regional"}>}X)/sum({<[Generations]={"Regional"}>} TOTAL X)

sum({<[Generations]={"Regional"}>}Y)/sum({<[Generations]={"Regional"}>} TOTAL Y)


And, set the percentage in the Number tab..

Not applicable
Author

Hi settu_periasamy,

Unfortunately the expression you suggested didn´t work.

It displayed all values with 100%:

pie.jpg

swuehl
MVP
MVP

Look at the alternative solution I suggested here:

Using multiple fields in a pie chart

i.e. use a dimension with one expression instead of three expression with no dimension. Then you can simply check the 'relative' option.

settu_periasamy
Master III
Master III

Hi Rodrigo,

Just to confirm,

Did you uncheck relative and set "Fixed to" and "Show in percentage" in Number Tab.

Or,

=Num(YourExpression,'#.##0%')   -> Expression Default in Number Tab