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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
pepe2209
Creator
Creator

Drop field under condition

Hello,

I was wondering if it is possible to drop fields in the script if they fit certain conditions. See example:

IDA1A2A3
112100
223440
3350
414230

So in this case I would like to drop field A3 because all values are 0.

something like:

IF(sum(A3)=0 THEN drop field A3 ENDIF

does not work.

Does anybody have an idea if this is possible? the goal is to limit the size of the document.

your help would be much appreciated.

regards

Peter

1 Solution

Accepted Solutions
Nicole-Smith

Michael Solomovich is correct in his response.  If seeing some working code will help you out more, here is an example:

data:

load * inline [

ID,A1,A2,A3

1,12,10,0

2,23,44,0

3,3,5,0

4,14,23,0

];

sums:

load sum(A3) as sumA3

resident data;

let vSumA3 = PEEK('sumA3');

if $(vSumA3) = 0 then

    drop field A3;

endif

drop table sums;

View solution in original post

3 Replies
Anonymous
Not applicable

It is possible.

IF <condition> THEN

<some script>

ELSE

<another script>

END IF

In your case, you don't need the ELSE part

Nicole-Smith

Michael Solomovich is correct in his response.  If seeing some working code will help you out more, here is an example:

data:

load * inline [

ID,A1,A2,A3

1,12,10,0

2,23,44,0

3,3,5,0

4,14,23,0

];

sums:

load sum(A3) as sumA3

resident data;

let vSumA3 = PEEK('sumA3');

if $(vSumA3) = 0 then

    drop field A3;

endif

drop table sums;

pepe2209
Creator
Creator
Author

Yes this is exactly what i need.

Thanks to both of you!