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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
brunopaulo
Partner - Creator II
Partner - Creator II

Transformation Excel in Script

Hi community,

I saw tons of tutorials about transformation wizard, and i'm trying replicate the power of that tool using functions.

I have something like dat

Field A      |     Field B      |     Field C     |     Field D     |      Field E

a                         e                    g                    h

b                         kj                    l                    ç    

c                         v                     i                    h    

d                         b                     l                    b

f                                                 

d                                                 l                    o

f                         f                         o                    i

So i want eliminate the lines bellow when in field B appear null for the 1st time. And i want elimate the columns dat have null values.

I tried something like this (for the columns with null values)

  1. FOR a = 0 TO NoOfTables() - 1 
  2.     LET vTable = TableName($(a)); 
  3.     LET d = 0
  4.     FOR i = 1 TO NoOfFields('$(vTable)'
  5.         LET j = i - d; 
  6.         LET vField = FieldName($(j), '$(vTable)'); 
  7.         LET vFieldValueCount = Alt(FieldValueCount('$(vField)'), 0); 
  8.         IF (vFieldValueCount <= 0 ) THEN 
  9.          DROP FIELD [$(vField)] FROM $(vTable); 
  10.          TRACE DROP FIELD [$(vField)] FROM $(vTable); 
  11.          LET d = d + 1; // dropping fields impacts the internal field no. 
  12.         END IF 
  13.        NEXT i 
  14.     NEXT a 

But always error for different reasons.
Thanks in advance
Best Regards
Bruno Paulo



1 Reply
el_aprendiz111
Specialist
Specialist

Hi Bruno

TRANSF_GENERIC.gif