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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

autofill empty field

Hi all,

i got a problem.

I got a filed with 3 values:

- A

- B

- empty

I need to replace the empty fields with "C", i'm trying to build a new field using if functions without success, any suggestion?

Thanks

Labels (1)
9 Replies
MayilVahanan
MVP
MVP

Hi

     Try like this,

     Load *, if(Len(Trim(Field)) > 0, FieldName, 'C') as fieldname from tablename;

     Hope it helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

but in the new field i should also keep A and B

MayilVahanan
MVP
MVP

Hi

     Len(Trim(FieldName)) gives the length of the field value, if is less than 1 means, it replace the empty string with 'C' otherwise it keeps the original value. so, A and B also there .

     If(Len(Trim(FieldName)) >0 , FieldName, 'C') gives A,B and C

Hope it helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

is not working...maybe the syntax is incorrect

CELAMBARASAN
Partner - Champion
Partner - Champion

Can you post the syntax you used?

MayilVahanan
MVP
MVP

Hi

     Check the attached file..

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

if(Len(Trim([Tipo ])) > 0, [Tipo],'C') as "AA"

In the new columns it gives me the correct field (a & b), but still left empty the empty ones

Not applicable
Author

I also tried with

if([Tipo]='A','A', if([Tipo]='B','B','C')) as "AAA"

and

If (IsNull([Tipo]),'C', [Tipo]) as "BBB"

but is still have no C

It seems like the fields are not empty, consider that they are populated as calculation of other fields

Not applicable
Author

 

This is a formatting problem

You need to format you inline as txt

 

Load

*
,
if(Len(Trim(Testing))<>0, Testing, 'C') as Test Inline
[
Testing,Value
A,1
B,2
,3
D,4
]
(TXT);