Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Loading IF statement

Hi,

I am struggling with the loading script using IF below, appreciate anyone's help :


[TCODE]:
LOAD fileNumber

if(([trackCode]='BOOKED') AND [TransportMode]={'B','V'}) as TB
if(([trackCode]='BOOKCONF) AND [TransportMode]={'P','T'}) as TD
resident [Shipment];

The shipment already has trackCode and TransportMode fields, the problem is the syntax error.

Thank you.

Regards,

AG

6 Replies
swuehl
MVP
MVP

Your if() statements need at least a THEN branch, and check your string value matching, like

if(([trackCode]='BOOKED') AND Match([TransportMode],'B','V'), 'Yipiieh!'  ) as TB

sunny_talwar

May be try this:

[TCODE]:
LOAD fileNumber

          If([trackCode]='BOOKED' and WildMatch([TransportMode], 'B','V'), 1, 0) as TB
          If([trackCode]='BOOKCONF' and WildMatch([TransportMode], 'P','T'), 1, 0) as TD
Resident [Shipment];

Chanty4u
MVP
MVP

ur missing single quote

[TCODE]:
LOAD fileNumber

if(([trackCode]='BOOKED') AND [TransportMode]={'B','V'}) as TB
if(([trackCode]='BOOKCONF') AND [TransportMode]={'P','T'}) as TD
resident [Shipment];

saniyask
Creator
Creator

Hi,

Please try this..

Untitled.png

Regards,

Saniya

Chanty4u
MVP
MVP

Hi,

It means i think Missing the single Quote

The shipment already has trackCode and TransportMode fields, the problem is the syntax error.
satishkurra
Specialist II
Specialist II

Extending to sunny syntax, we can use below in Red to give a meaningful name using Dual

[TCODE]:
LOAD fileNumber

          If([trackCode]='BOOKED' and WildMatch([TransportMode], 'B','V'), Dual('TransportModeBV',1), Dual('TransportModeNOTBV',0)) as TB
Resident [Shipment];