1 Reply Latest reply: Apr 21, 2011 8:18 AM by Adam Abwat-Johnson RSS

    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?

       

       

       

       

        • Calculating percentage using data from two different tables
          Adam Abwat-Johnson

          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