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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

count fields

hi all,

in a table with 5 fields:

ID,

A,

B,

C,

D

where fields A, B, C, D have numerical values, i want to add a field to this table in my LOAD script telling me the number of fields (only A, B, C and D) that are 0.

Example:

ID
A
B
C
D
XYZ5021

Adding the niew field the table shall look like this:

ID
A
B
C
D
# of zeros
XYZ50211

Thanks a lot for some ideas!

1 Solution

Accepted Solutions
swuehl
MVP
MVP

LOAD

ID,

A,

B,

C,

D,

-1*rangesum(A=0,B=0,C=0, D=0) as NrOfZeros

from Table;

View solution in original post

3 Replies
swuehl
MVP
MVP

LOAD

ID,

A,

B,

C,

D,

-1*rangesum(A=0,B=0,C=0, D=0) as NrOfZeros

from Table;

CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

     Try with this

    

Load

       ID,

       A,

     B,

     C,

     D,

      RangeSum(If(A=0,1),If(B=0,1),If(C=0,1),If(B=0,1)) as NumCount

From..

Celambarasan

jagan
Partner - Champion III
Partner - Champion III

Hi,

Use the following script, with a little change to Stefan's script.  Used fabs() instead -1*

LOAD

*,

fabs(RangeSum(A=0, B=0, C=0, D=0)) AS zeroCount;

LOAD * INLINE [

    A, B, C, D

    1, 0, 0, 1

    76, 0, 8, 7

    0, 0, 0, 0

];

Regards,

Jagan.