Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Toya2323
Contributor
Contributor

Percent of Whole in pivot table

I'm trying to figure out the part (%) of the whole of the population from the below dataset in a pivot table.  I know what the answer should be but I need help with the "% of Population".

Calculation for % of Cities:

if(

([Sunny]='Y' and [Rain]='Y')or

([Sunny]='Y' and [Rain]='N') or

([Sunny]='N' and [Rain]='Y') or

([Sunny]='N' and [Rain='N'),

(Count([Cities])/(Count(Total [Cities])))

)

This is where the error is - Calculation for % of Population:

if(

([Sunny]='Y' and [Rain]='Y')or

([Sunny]='Y' and [Rain]='N') or

([Sunny]='N' and [Rain]='Y') or

([Sunny]='N' and [Rain='N'),

(Sum([Cities])/(Sum(Total [Cities])))

)

My answer is 1 instead of the below values.

 

SunnyRainCitiesPopulation
ynDallas 90
ynSan Antonio88
nnAustin82
yyLaredo85
nyHouston80
nnLubbock82
yyFt Worth93
nyEl Paso84
yyArlington 91
nnCorpus Christi96
ynPlano92
nyGarland86
nnIrving87
ynAmarillo94
ny

Grand Prairie

76

   

Results
SunnyRain# of Cities% of Cities% of Population
YY320.00%20.60%
YN426.67%27.87%
NY426.67%24.96%
NN426.67%26.57%

2 Replies
andrey_krylov
Specialist
Specialist

Hi, Dineen. Try Sum(Population)/Sum(TOTAL Population) for "% of Population"

Toya2323
Contributor
Contributor
Author

This measure is in a Pivot Table.  Rows are Sunny and Rain

When I try the following

if(

([Sunny]='Y' and [Rain]='Y')or

([Sunny]='Y' and [Rain]='N') or

([Sunny]='N' and [Rain]='Y') or

([Sunny]='N' and [Rain='N'),

(Sum([Population])/(Sum(Total [Population])))

)

or Sum(Population)/Sum(TOTAL Population)

I get 1 as the answer