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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Division in same field

Hi experts,

Below is the table

    A    B    C

    1    2    0/18

    4    3    0.27

    5    6    0.54

Requirement:

C = B/SUM(B)

eg : 2/11

Below is my load script

tableA:

Load

    A,

    B,

    Sum(B) as totalB

from ...

group by A,B;

tableB:

Load

    A,

    B,

    totalB,

    B/totalB as C

Resident tableA;


drop table tableA;


this codes will produce this result

    A    B    C

    1    2    1

    4    3    1

    5    6    1


because this formula B/totalB = B/B


Any idea how?


Thank you in advance!

1 Solution

Accepted Solutions
DavidŠtorek
Creator III
Creator III

Hi,

do you want to sum B for each value of A or jus total of B (like 2+3+6)?

If the second option is valid than you have to create a variable.

tableA:

Load

      Sum(B) as totalB

from ...;

Let vTotalB= Peek('totalB',0, 'tableA');

Drop Table tableA;

tableB:

Load

    A,

    B,

    $(vTotalB) as totalB,

    B/$(vTotalB) as C

from ...;


Hope this helps

View solution in original post

5 Replies
DavidŠtorek
Creator III
Creator III

Hi,

do you want to sum B for each value of A or jus total of B (like 2+3+6)?

If the second option is valid than you have to create a variable.

tableA:

Load

      Sum(B) as totalB

from ...;

Let vTotalB= Peek('totalB',0, 'tableA');

Drop Table tableA;

tableB:

Load

    A,

    B,

    $(vTotalB) as totalB,

    B/$(vTotalB) as C

from ...;


Hope this helps

DavidŠtorek
Creator III
Creator III

Check attached app if you want

Anonymous
Not applicable
Author

Hi

Instead of performing the calculations at script level you can perform the same at front end.

Thanks

Anonymous
Not applicable
Author

Hi,

superb answer!

Thanks

Anonymous
Not applicable
Author

Hi,

There's a reason i want to do it at back end. thanks!