Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to write expression to add column into table

Hi,

I have expression as below.

when I am using this it is showing error as Error in expression:If takes 2-3 parameters

If(MixMatch(Zinc,'Present',

        IF (MixMatch( Coal,'Marbel Transfer'),'Ready',

            If(MixMatch(Zinc,'XX','YY','CC','SS','VV'),'Ready',

              If(MixMatch(Coal,'NOTXX','NOTYY','NOTSS','NOTCC','NOTZZ',

                  If (Not Match(Coal,'Marbel Transfer'),'Ready')))))))) as [Ready],

Please can anyone suggest me how to set this?

Thanks.

1 Solution

Accepted Solutions
sunny_talwar

One issue I see in the qvw you have attached is that the Coal column is almost empty

If.PNG

Is the goal is to fill NotReady everywhere we don't have Ready in column Ready? If that is the goal you can probably use this:

If((Zinc = 'Present' and Coal = 'Marbel Transfer') or (MixMatch(Zinc, 'XX', 'YY', 'CC', 'SS', 'VV')), 'Ready', 'NotReady')) as Ready

View solution in original post

21 Replies
sunny_talwar

Your if statement doesn't make sense. If Coal matchs 'Marbe Transfer' [Ready] should have value 'Ready' and if it doesn't match 'Marbe Transfer' again it is called 'Ready'??

If(MixMatch(Zinc,'Present',

       IF (MixMatch( Coal,'Marbel Transfer'),'Ready',

            If(MixMatch(Zinc,'XX','YY','CC','SS','VV'),'Ready',

              If(MixMatch(Coal,'NOTXX','NOTYY','NOTSS','NOTCC','NOTZZ',

                  If (Not Match(Coal,'Marbel Transfer'),'Ready')))))))) as [Ready],

If your provide the logic, we might be able to provide you with a better if statement.

With regards to the error:

You are missing ,'Ready' for your first If statement

=If(MixMatch(Zinc,'Present'), 'Ready',

IF(MixMatch(Coal,'Marbel Transfer'),'Ready',

If(MixMatch(Zinc,'XX','YY','CC','SS','VV'),'Ready',

If(MixMatch(Coal,'NOTXX','NOTYY','NOTSS','NOTCC','NOTZZ',

If(Not Match(Coal,'Marbel Transfer'),'Ready')))))) as [Ready]

I hope this helps.

Best,

Sunny

Not applicable
Author

sorry I should have use NotReady in above line where there is Not match.

Please see below this is my requirement:

my excel sheet have below columns

ExcelA:

Date         Id         Name         Zinc        Coal        Spent


I have to insert one column 'Ready' in between 'Zinc' and 'Coal' in ExcelA sheet

for that I have to use condition as below

when Zinc = 'Present' and Coal = 'Marbel Transfer' then  [Ready] = Ready
when Zinc = 'XX','YY','CC','SS','VV' then [Ready] = Ready
When Zinc = 'NOTXX','NOTYY','NOTSS','NOTCC','NOTZZ' and Coal not equal to 'Marbel Transfer' then [Ready] = NotReady

how can I write script by using above conditions. Please help.

sunny_talwar

Still not sure about this:

When Coal = 'NOTXX','NOTYY','NOTSS','NOTCC','NOTZZ' and Coal not equal to 'Marbel Transfer'


Because if Coal is NOTXX, then it def. won't be Marbel Transfer (so there is no point checking for Coal not equal to 'Marbel Transfer' here. Try the below if the conditions you have given me is what you are looking for:


If((Zinc = 'Present' and Coal = 'Marbel Transfer') or (MixMatch(Zinc, 'XX', 'YY', 'CC', 'SS', 'VV')), 'Ready',

If(MixMatch(Coal, 'NOTXX','NOTYY','NOTSS','NOTCC','NOTZZ'), 'NotReady')) as Ready



I hope this will help.

Best,

Sunny

Not applicable
Author

sorry there is typo mistake. I edited it. Please see below

when Zinc = 'Present' and Coal = 'Marbel Transfer' then  [Ready] = Ready

when Zinc = 'XX','YY','CC','SS','VV' then [Ready] = Ready

When Zinc = 'NOTXX','NOTYY','NOTSS','NOTCC','NOTZZ' and Coal not equal to 'Marbel Transfer' then [Ready] = NotReady

PrashantSangle

Hi,

use if with wildmatch()

try like

if(WildMatch(Zinc,'Present') and wildmatch(Coal,'Marbel Transfer'),'Ready',

if(wildmatch(Zinc,'XX','YY','CC','SS','VV'),'Ready',

if(wildmatch(Coal,'NOTXX','NOTYY','NOTSS','NOTCC','NOTZZ','Marbel Transfer'),'Not Ready')

)

) as Ready_NotReady_Flag

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
PrashantSangle

Hi,

use if with wildmatch()

try like

if(WildMatch(Zinc,'Present') and wildmatch(Coal,'Marbel Transfer'),'Ready',

if(wildmatch(Zinc,'XX','YY','CC','SS','VV'),'Ready',

if(wildmatch(Zinc,'NOTXX','NOTYY','NOTSS','NOTCC','NOTZZ') and wildmatch(Coal,'Marbel Transfer'),'Not Ready')

)

) as Ready_NotReady_Flag

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
sunny_talwar

Try this:

If((Zinc = 'Present' and Coal = 'Marbel Transfer') or (MixMatch(Zinc, 'XX', 'YY', 'CC', 'SS', 'VV')), 'Ready',

If(MixMatch(Zinc, 'NOTXX','NOTYY','NOTSS','NOTCC','NOTZZ'), 'NotReady')) as Ready

maxgro
MVP
MVP

if(

  (Zinc='Present' and Coal='Marbel Transfer')

  or    (match(Zinc, 'XX','YY','CC','SS','VV'))

  or     (match(Zinc, 'NOTXX','NOTYY','NOTSS','NOTCC','NOTZZ') and Coal<>'Marbel Transfer'),

       'Ready',

       'Not ready'

  ) as Ready

sunny_talwar

Forgot to update the last formula (Use this one and disregard the last one)

If((Zinc = 'Present' and Coal = 'Marbel Transfer') or (MixMatch(Zinc, 'XX', 'YY', 'CC', 'SS', 'VV')), 'Ready',

If(MixMatch(Zinc, 'NOTXX','NOTYY','NOTSS','NOTCC','NOTZZ') and Coal <> 'Marbel Transfer', 'NotReady')) as Ready