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.
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.