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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Scripting

Hi Team,

Can any one give the solution.

These are actual table fields.

A               B         C

Health        3         -

Health        -         15

but I require B/C in scripting.

Thanks

krish

15 Replies
sunny_talwar

You require B/C in scripting? You want to be able to divide them?

May be like this:

LOAD A,

          Sum(B)/Sum(C) as [B/C]

From ...

Group By A;

avinashelite

something like this

LOAD A,

if(len(trim(B))>0,B,C) as B_C

from table ;

could  you please explain what is the output your excepting ??

Mark_Little
Luminary
Luminary

Hi,

Just confirm should the final data look like

Health      3          15

Probably something like

DataTemp:

Load

     A,

     B

From ...

Where LEN(B) > 0;

Join

Load

     A,

     C

From ...

Where LEN(C) > 0;

NoConcatenate

Data:

LOAD

     A,

     B,

     C,

     B / C AS D

RESIDENT DataTemp;

Drop table DataTemp;

Mark

Not applicable
Author

Hi Sunny,

Did not get that scripting. It is returns the invalid expression.

I require Division of B/C.

Thanks

krish

sunny_talwar

Did you use Group By Statement?

Not applicable
Author

Hi Avinash,

I require only Division of B/C.

Thanks

Giri

Not applicable
Author

Yes

Anonymous
Not applicable
Author

Hi,

Try this code:

MyTable:

LOAD * INLINE [

    A, B, C

    Health,3,

    Health,,15

];

Final:

LOAD

    A,

    Sum(If(IsNull(B),0,B)) as SumB,

    Sum(If(IsNull(C),0,C)) as SumC,

    IF(Sum(If(IsNull(C),0,C)) = 0,0,

        Sum(If(IsNull(B),0,B))/Sum(If(IsNull(C),0,C))) as [B/C]

RESIDENT MyTable

Group By A;

Use IsNull to set 0 when B or C is null, if Sum(C) is null it will return 0 on B/C field.

Regards!

Not applicable
Author

Hi Sunny,

I require B,C fields also. It is possible to without B,C fields.