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

How to write If statement in script level

Hi Everybody.

I have tried one logic but i did't get exact value, My script is below

If the Type = X, multiply the sales * -1, insert the amount into Rebates LC and set sales to 0.....

here Type , Sales, Rebates all are different fields,

Thanks in Advance

Munna@

1 Solution

Accepted Solutions
Peter_Cammaert
Partner - Champion III
Partner - Champion III

:

IF (Type='X', 0, Sales) AS Sales,

IF (Type='X', Sales * (-1), 0) AS [Rebates LC],

:

Best,

Peter

View solution in original post

6 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

:

IF (Type='X', 0, Sales) AS Sales,

IF (Type='X', Sales * (-1), 0) AS [Rebates LC],

:

Best,

Peter

er_mohit
Master II
Master II

try this

if(Type='X',(Sales*(-1)),Rebates)

alexandros17
Partner - Champion III
Partner - Champion III

SELECT (or LOAD)

...    

if(Type= 'X', Sales * -1, Sales) as [Rebates LC],

if(Type= 'X', 0, Sales) as Sales,

...

MK_QSL
MVP
MVP

Load

     your fields,

     If(Type = 'X', sales*-1) as [Rebates LC],

     if(Type = 'X', 0, sales) as sales;

From TableName;

Not applicable

HELP PLEASE

Why does the IF portion not work ??

 

ODBC

CONNECT32 TO QED208;
SQL SELECT dtcrash as crash_dtcrash,
crashnum as crash_crashnum,
month(dtcrash) as crash_month,
year(dtcrash) as crash_year,
loctype as crash_locationtype,
hrmfeventdesc2 as crash_desc,
weathcond1desc as crash_weather,
roadsurfdesc as crash_roadsrufacecond,
manrcolldesc as crash_mandesc,
rdwyjuncdesc as crash_rdyjunction,
intrdwy1name as crash_road1,
intrdwy2name as crash_road2,
nointstnum as crash_stnum,
nointstname as crash_street,
hrmfeventcode2 as crash_hrmfeventcode2
FROM uqed.xacreports where ((date(dtcrash) >= (40909)));

SELECT if(nointstnum >'',nointstname,road1) as crash_location;

PrashantSangle

Hi,

Try your if with load Statement instead of Select Statement.

Like

ODBC

CONNECT32 TO QED208;

Test1:

SQL SELECT dtcrash as crash_dtcrash,
crashnum as crash_crashnum,
month(dtcrash) as crash_month,
year(dtcrash) as crash_year,
loctype as crash_locationtype,
hrmfeventdesc2 as crash_desc,
weathcond1desc as crash_weather,
roadsurfdesc as crash_roadsrufacecond,
manrcolldesc as crash_mandesc,
rdwyjuncdesc as crash_rdyjunction,
intrdwy1name as crash_road1,
intrdwy2name as crash_road2,
nointstnum as crash_stnum,
nointstname as crash_street,
hrmfeventcode2 as crash_hrmfeventcode2
FROM uqed.xacreports where ((date(dtcrash) >= (40909)));

Test2:
Load *,if(nointstnum >'',nointstname,road1) as crash_location

Resident Test1;


Drop tables Test1;

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂