Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
deepakqlikview_123
Specialist
Specialist

Code

Hi all,

Can you please suggest what would be optimized code for code given below.

if(FuelType='Diesel' or FuelType='DIESEL','Diesel',If(FuelType='LPG','LPG',If(FuelType='CNG','CNG')))as FuelType

If fuel type is Diesel or DIESEL then i need to display DIESEL or if fuel type is CNG then CNG and if LPG then LPG.

Thanks,

Deepak

Labels (1)
6 Replies
its_anandrjs
Champion III
Champion III

You can try with

if(Match(FuelType='Diesel','DIESEL'),'DIESEL',

If(Match(FuelType='LPG'),'LPG',

If(Match(FuelType='CNG'),'CNG'))) as FuelType


preminqlik
Specialist II
Specialist II

Load *,

upper(trim(FuelType) )              as          NewFuelType

from path;

its_anandrjs
Champion III
Champion III

Another way is

Load

Trim(if(Match(FuelType='Diesel','DIESEL'),'DIESEL',

       If(Match(FuelType='LPG'),'LPG',

       If(Match(FuelType='CNG'),'CNG'))) ) as FuelType

From Location;

deepakqlikview_123
Specialist
Specialist
Author

Hi Anand,

It is giving me syntax error.

NareshGuntur
Partner - Specialist
Partner - Specialist

Hi Deepak,

Try this

if(Upper(FuelType)='DIESEL','DIESEL',if(Upper(FuelType)='LPG','LPG',if(Upper(FuelType)='CNG','CNG')))

anbu1984
Master III
Master III

=if(Match(FuelType,'Diesel' ,'DIESEL','LPG','CNG'),Upper(FuelType))