Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
etrotter
Creator II
Creator II

Using WildMatch in an IF function?

Hi Everyone,

I am working to create two new field based on a id

The ID looks like this:

123-16

234-17

556P

345P

234-15

I would like to create an if statement in the script that separates the P from the -##, but I haven't been able to get it to load. I want the "P" to be named primary, and the -## to be named historical. 

if you can help I would appreciate it!

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Maybe some simple string functions already are sufficient to separate your field values:

LOAD

     if(Right([%ClimateWorksID],1)='P', [%ClimateWorksID]) as [Primary Porfolio ID],

     if(Mid([%ClimateWorksID],4,1)='-', [%ClimateWorksID]) as [Historic Porfolio ID];

LOAD * INLINE [

%ClimateWorksID

123-16

234-17

556P

345P

234-15

];

View solution in original post

4 Replies
etrotter
Creator II
Creator II
Author

I think I'm close

if(WildMatch([%ClimateWorksID]='###P',1,0), [%ClimateWorksID]) as [Primary Porfolio ID],

swuehl
MVP
MVP

Maybe some simple string functions already are sufficient to separate your field values:

LOAD

     if(Right([%ClimateWorksID],1)='P', [%ClimateWorksID]) as [Primary Porfolio ID],

     if(Mid([%ClimateWorksID],4,1)='-', [%ClimateWorksID]) as [Historic Porfolio ID];

LOAD * INLINE [

%ClimateWorksID

123-16

234-17

556P

345P

234-15

];

Clever_Anjos
Employee
Employee

Or using index() function

LOAD

     if(index([%ClimateWorksID],'P'), [%ClimateWorksID]) as [Primary Porfolio ID],

     if(index([%ClimateWorksID],'-'), [%ClimateWorksID]) as [Historic Porfolio ID];

LOAD * INLINE [

%ClimateWorksID

123-16

234-17

556P

345P

234-15

];

Saravanan_Desingh

Also..

if(WildMatch([%ClimateWorksID],'*P'), [%ClimateWorksID]) as [Primary Porfolio ID],

if([%ClimateWorksID] Like '*-*', [%ClimateWorksID]) as [Historic Porfolio ID];