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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
YanivZi
Contributor III
Contributor III

Sum 2 fields into pie chart

I have 3 fields:

  • city,
  • cost1,
  • cost2

I want to make pie chart that has 1 demission of the city and 2 measures of the sum cost1 and the sum cost2.  

so if sum of cost 1 is 27% of the total and cost2 is 73% of the total the chat should look like that:

 

pie chartpie chart

I tried to do it but the widget has only 1 measure

Labels (1)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

Assuming your data is as below, create a dummy dimension  to use in the pie chart

 

 

 

Table:
load * inline [
City,Cost1,Cost2
A,100,300
B,200,900
];

DummyDim:
Load * inline [
CostType,so_Ctype
Cost1,1
Cost2,2
];

exit script;

 

 

 

then in chart  use

Dimension

=CostType

Measure

=Pick(so_Ctype, Sum(Cost1)/ sum(Cost1+Cost2), Sum(Cost2)/ sum(Cost1+Cost2) )

 

cost 1=  300 / 1500

cost 2 = 1200/ 1500

 

Capture.PNG

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

1 Reply
vinieme12
Champion III
Champion III

Assuming your data is as below, create a dummy dimension  to use in the pie chart

 

 

 

Table:
load * inline [
City,Cost1,Cost2
A,100,300
B,200,900
];

DummyDim:
Load * inline [
CostType,so_Ctype
Cost1,1
Cost2,2
];

exit script;

 

 

 

then in chart  use

Dimension

=CostType

Measure

=Pick(so_Ctype, Sum(Cost1)/ sum(Cost1+Cost2), Sum(Cost2)/ sum(Cost1+Cost2) )

 

cost 1=  300 / 1500

cost 2 = 1200/ 1500

 

Capture.PNG

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.