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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculating percentage using data from two different tables

Hi,

I have inserted data from two different tables of SQL in a Qlikview file. I want to calculate percentage by using data from both these table which contains same columns.

Example: There are some hours in Column1 of Table A

There are some hours in Column1 of Table B and Column name is Same as Table A

I want to divide hours of Table A by Hours from Table B but I am not getting correct percentage.

Can anyone please help with Formula?

1 Reply
chris_johnson
Creator III
Creator III

Hi,

If I understand correctly then QlikView will probably join the two tables on the same column name. What you may want to do is put something into your script when you are loading the tables to say which table it is from. For example:

load

...

'TableA' as SourceTable;

from ...

This way you can distinguish between the two tables.

Then your expression would be something like:

sum ({<SourceTable={'TableA'}>} "Total Hours") / sum ({<SourceTable={'TableB'}>} "Total Hours")

I'm not sure how familiar you are with Set Analysis but I think it is supposed to be quicker than using IF statements.

Chris