Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
bharatkishore
Creator III
Creator III

Match Function

Hi All,

I have an Entitlement field there i have C,T,W

Now i have When ever i select C it should show 1 then if i select T is should be 0 then if i select warranty it should show 1.

Condition i have written is If(Match(Entitlement, 'Contract ', 'T&M', 'Warranty'), 1, 0) as KPI

But i am getting wrong result for C it is 0 and for T and W it is 1 .

Can you please tell me where i am doing wrong.

Attached qvw for more reference.

1 Solution

Accepted Solutions
tamilarasu
Champion
Champion

Hi Bharat,

If(Match(Entitlement, 'Contract','Warranty'), 1, 0) as KPI

View solution in original post

6 Replies
YoussefBelloum
Champion
Champion

Hi,

you can try this:

Pick(Match(Entitlement,'C','T','W'),'1','0','1')

tamilarasu
Champion
Champion

Hi Bharat,

If(Match(Entitlement, 'Contract','Warranty'), 1, 0) as KPI

bramkn
Partner - Specialist
Partner - Specialist

The match function works like this:

ExampleResult
match( M, 'Jan','Feb','Mar')

returns 2 if M = Feb.

returns 0 if M = Aprorjan.

If you want T to be False/0 you should remove it from the match function:

if(Match(Entitlement, 'Contract', 'Warranty'),1,0)

With this it checks if the Entitlement is matched with one of these values. and returns the number of it. If it does this it wil return true and give 1 with the if statement. If not the if gives 0.

Oh and you had a tailing space with the contract string.

bharatkishore
Creator III
Creator III
Author

Thanks a lot.

Can you please tell me where did i miss with my expression and why it is not working.

Thanks,

Bharat

tamilarasu
Champion
Champion

Sure.

1). While typing you have included a space after "Contract" by mistake.

Match(Entitlement, 'Contract ', 'T&M', 'Warranty')

2) Also your If condition is not correct. Your "If" condition says that If the Entitlement field is match with "Contract" or "T&M" or "Warranty" then KPI should be 0 and for the remaining entitlement it should be 1. That is basically wrong as per your requirement.

The condition should be


If(Match(Entitlement, 'Contract','Warranty'), 1, 0) as KPI   (If Entitlement is "Contract" or "Warranty" then KPI should 1 and for the rest it should be 0)


Hope I have explained clearly.

bharatkishore
Creator III
Creator III
Author

Thank you so much... Thanks a lot...