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

Pivot Table Partial Percentage

Hello

I´ve been looking for this answer into the community and there are some similar topics but there are not a complete answer at all.

In addition of the partial sum, I need to show the % of the total sum

Pivot Table %.JPG

Ingresos, Costos, Gastos and Utilidad are expressions as a result of a algebraic operation from my database. As you can see, INGRESOS is the base to calculate all the others (COSTOS, GASTOS and UTILIDAD)

I will appreciate your help

1 Solution

Accepted Solutions
sunny_talwar

Is this what you want?

Capture.PNG

I will try to go step by step, but let me know if you still are not clear about something

1) Add an inline load at the end of your script.

Dim:

LOAD * Inline [

Dim

1

2

3

];

Capture.PNG

Modify your chart like this

Dimensions

Dim 1 change from Mes to

=Pick(Dim, MES, 'Total', 'Percent')

Dim 2 change from Clase to

=Pick(Dim, Clase, Dual(' ', 1), Dual(' ', 2))

Capture.PNG

Expressions changed to theses

1) Pick(Dim,

Num(Sum({<Descrip_Nivel_1 = {'INGRESOS'}>} Valor), '$ #.##0'),

Num(Sum({<Descrip_Nivel_1 = {'INGRESOS'}>} Valor), '$ #.##0'),

Num(1, '##,0%'))

2) Pick(Dim,

Num(Sum({<Descrip_Nivel_1 = {'COSTOS DE PRODUCCION O DE OPERACION'}>} Valor), '$ #.##0'),

Num(Sum({<Descrip_Nivel_1 = {'COSTOS DE PRODUCCION O DE OPERACION'}>} Valor), '$ #.##0'),

Num(Sum({<Descrip_Nivel_1 = {'COSTOS DE PRODUCCION O DE OPERACION'}>} Valor)/Sum({<Descrip_Nivel_1 = {'INGRESOS'}>} Valor), '##,0%'))

3) Pick(Dim,

Num(Sum({<Descrip_Nivel_1 = {'GASTOS'}>} Valor), '$ #.##0'),

Num(Sum({<Descrip_Nivel_1 = {'GASTOS'}>} Valor), '$ #.##0'),

Num(Sum({<Descrip_Nivel_1 = {'GASTOS'}>} Valor)/Sum({<Descrip_Nivel_1 = {'INGRESOS'}>} Valor), '##,0%'))

4) Pick(Dim,

Num(INGRESOS+COSTOS+GASTOS, '$ #.##0'),

Num(INGRESOS+COSTOS+GASTOS, '$ #.##0'),

Num(INGRESOS+COSTOS+GASTOS/Sum({<Descrip_Nivel_1 = {'INGRESOS'}>} Valor), '##,0%'))

Some other changes

1) Uncheck partial sum for Mes dimension

2) Added a color formatting for background color for the 2 dimensions and all the 4 expressions

Capture.PNG

Expression used for color

=If(Match(Dim, 2, 3), RGB(192,192,192))

Expression used for Format

=If(Match(Dim, 2, 3), '<B>')

Once you do all the above, you should almost reach what I have posted above. Let me know if you still have issues. Also, I know you are working with personal addition of QlikView, I will still attach the sample as it may help somebody else in the future.

Best,

Sunny

View solution in original post

16 Replies
sunny_talwar

What are the expressions you are using here?

Anil_Babu_Samineni

Copy paste those expressions and check Relative from Expression Tab which you need % and then see how works / Else As Sunny T asked, You may share those

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable
Author

Following the expressions:

INGRESOS  sum(if(Descrip_Nivel_1='INGRESOS', Valor))

COSTOS     sum(if(Descrip_Nivel_1='COSTOS DE PRODUCCION O DE OPERACION', Valor))

GASTOS     sum(if(Descrip_Nivel_1='GASTOS', Valor))

UTILIDAD   INGRESOS+COSTOS+GASTOS

thanks a lot

Anonymous
Not applicable
Author

Anil Babu, thank you for your answer.

In this case I think is necesary to change from pivot table to simple table in order to get activated the Relative check box. Anyway I can´t get the result.

sunny_talwar

How about this:

INGRESOS:     1


COSTOS:          Sum(if(Descrip_Nivel_1='COSTOS DE PRODUCCION O DE OPERACION',                           Valor))/Sum(if(Descrip_Nivel_1='INGRESOS', Valor))

GASTOS:          Sum(if(Descrip_Nivel_1='GASTOS', Valor))/Sum(if(Descrip_Nivel_1='INGRESOS', Valor))

UTILIDAD:         Sum(if(Descrip_Nivel_1='GASTOS', Valor))/Sum(if(Descrip_Nivel_1='INGRESOS', Valor))

Also, I believe that you can simplify your expressions using set analysis instead of using if statement. For example INGRESOS can be like this

Sum({<Descrip_Nivel_1 *= {'INGRESOS'}>} Valor)

instead of what you have today. I did not offer the change above because I am not sure if there is a reason you used if instead of set analysis

Anonymous
Not applicable
Author

Sunny, thank you very much

You are right about using set analysis instead of IF statement.

By the way, I used the expressions you suggested, and this is the result

pivot table con %.JPG

Maybe there is something I am not doing well at all. I need to put the result under the $ values row.

sunny_talwar

So the total row should be in percentage? Would you be able to share a sample where we can work on getting your requirement accomplished?

Anonymous
Not applicable
Author

Yes, exactly, a row like a total. The example would be like as the image I attached at first.