Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

davlunhkc
New Contributor

Replace

Hi,

We are trying to import text files into a temporary textfile and post each "filedata" on a new row.

The script does not replace "D180222" with "ABC" on any row in the "Tempdata" textfile

Tempdata:

LOAD

Filename() as filnamn,

Replace("@1:n",'D180222', 'ABC') as DatarowInfo

FROM [lib://folder/D180222.*.txt]

(fix, codepage is 28591, no labels);

Thanks in advance

5 Replies

Re: Replace

What exactly is this? @1:n, a field name? and in this field you want to replace D180222 with ABC?

zebhashmi
Valued Contributor

Re: Replace

look like it would be

Replace ('D180222', 'D180222','ABC')

if you want to do it through replace

davlunhkc
New Contributor

Re: Replace

Thanks guys,

I managed to figure this out by myself at last but thanks for your help.

juraj_misina
Valued Contributor

Re: Replace

Hi,

I have two ideas.

1. I'm a fan of square brackets, try using those instead of double quotes for the @ notation:

Replace([@1:n],'D180222', 'ABC') as DatarowInfo

2. try using preceding load, maybe the Replace() function got confused by the @ notation:

Tempdata:

LOAD

filnamn,

Replace(DatarowInfo,'D180222', 'ABC') as DatarowInfo

;

LOAD

Filename() as filnamn,

[@1:n] as DatarowInfo

FROM [lib://folder/D180222.*.txt]

(fix, codepage is 28591, no labels);

Hope this helps.

Juraj

OmarBenSalem
Esteemed Contributor

Re: Replace

Not sure what u want u mean but @1:n , but it seems to me that u want to replace every value of every field of ur table.

sthing like for i= to n do ... ?

Well if that's the case :

let's suppose u have this:

t:

col1,col2,col3,col4

value1x,value2x,value3x,value4x

value11x,value22x,value33x,value44x

value111x,value222x,value333x,value444x

value1111x,value2222x,value3333x,value4444x

value111111x,value22222x,value33333x,value44444x

];

and u want to replace every x in every column by ABC

here what u do :

t:

load RowNo() as row,* Inline [

col1,col2,col3,col4

value1x,value2x,value3x,value4x

value11x,value22x,value33x,value44x

value111x,value222x,value333x,value444x

value1111x,value2222x,value3333x,value4444x

value111111x,value22222x,value33333x,value44444x

];

final:

load row  Resident t;

let nOffield=NoOfFields('t');

for i=2 to $(nOffield)

LET Field = FieldName(i,'t');

left join(final)

load row , Replace($(Field),'x','ABC') as $(Field) Resident t;

next i

drop Table t;



Result:

Capture.PNG

Community Browser