Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

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
Not applicable

Re: Loading IF statement

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
Not applicable

Re: Loading IF statement

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
Not applicable

Re: Loading IF statement

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
Not applicable

Re: Loading IF statement

Hi,

Please try this..

Untitled.png

Regards,

Saniya

Chanty4u
Not applicable

Re: Loading IF statement

Hi,

It means i think Missing the single Quote

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

Re: Loading IF statement

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];