Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Replacing value using Calculation

Hi All,

I am scanning a filed in a table for numeric value using IsNum function. The condition is if the value is not a number then the value should be changed with a value from different table:

Table 1
AB
1aaa
2bbb
3ccc

Table 2
AC
100001
200002
3Null

In Table 2, row number 3 has a NULL value and hence it should be replaced with ccc from Table 3.

The query I am using in Table 2 is:

if(isnum(C)=-1,C,B) as New_Filed

Thanks in Advance

6 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Make Table 1 into a mapping table.

Then replace your expression in Table 2 with

if (IsNum(C), C, applymap('Table1',A)) as New_Field

However the IsNum() function may have trouble detecting numerical values in a mixed-type column.

Peter

MayilVahanan

HI

Try like this

Table1:

Mapping

Load * Inline

[

A,B

1,aaa

2,bbb

3,ccc

];

Table2:

LOAD *, if(IsNum(C), C, ApplyMap('Table1',A, 0)) As B;

LOAD * Inline

[

A,C

1,00001

2,00002

3,Null

];

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

Hi Peter,

Following is our query for Map Load:

A1:

Mapping Load

A,B

Resident Table1;

And we used your query to replace the value/ Now we are getting an error which state "File B not found"

israrkhan
Specialist II
Specialist II

Hi,

1) In your table 2, C Values 00001, 00002 are not numeric value, these are text values,

numeric or integer value can not have 0 before any digit, like 002 will be equal to 2, and when you will check

if(c=2), i will return false... if c contain 002.

2) If you are reading data from sql server, and when you will check if(c= -1), and if c contain NULL,

it will not return you true, or false , it will return you Unknown.

so isnum() will not work in this case...

Not applicable
Author

Hi Guys,

Based upon the reply given by Israr, I have to change my Table 2 as follows:

Table 2
AC
1762
2145
3
israrkhan
Specialist II
Specialist II

Hi.

add another condition to check null in your existing condition as below

if (isnum(c )) OR IF(ISNULL(C)).