Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I wanna this CASE statement translate in Qlik script.
CASE
WHEN Kontaktfehler =1 THEN 1
WHEN HSpgFehler =1 or HSpgFehlerW =1 THEN 2
WHEN Weg1 =1 or Weg1W =1 THEN 3
ELSE 0
END as Errorcode,
grateful for any help
Thanks.
Should be like this
If(Kontaktfehler = 1, 1,
If(HSpgFehler = 1 or HSpgFehlerW = 1, 2,
If(Weg1 =1 or Weg1W =1, 3, 0))) as Errorcode
Modified my expression based on Shivesh's response
You can use If statement here or while loading from DB, you can use case there itself
Should be like this
If(Kontaktfehler = 1, 1,
If(HSpgFehler = 1 or HSpgFehlerW = 1, 2,
If(Weg1 =1 or Weg1W =1, 3, 0))) as Errorcode
Modified my expression based on Shivesh's response
Thank you, it works.
Let vToday = Floor(today()-180);
ODBC CONNECT TO viebjsql_daten;
K0_K1:
Load*, If(KontaktFehler = 1, 1,
If(HSpgFehler = 1 or HSpgFehlerW = 1, 2,
If(WegFehler1 =1 or WegFehler1W =1, 3, 0))) as Errorcode;
SQL SELECT *
FROM "PrfDat_ENTW".dbo."schuetzprf_K0_K1_agg1" WHERE "Prüfdatum" >$(vToday);
Hi Sunny
There should be a comma also after 1 and 2 to make it else if..or it will work too..
If(Kontaktfehler = 1, 1 here
If(HSpgFehler = 1 or HSpgFehlerW = 1, 2 here
If(Weg1 =1 or Weg1W =1, 3, 0))) as Errorcode
Yes comma is needed.
Hahahaha yes, you are right... fixing my response now
Great
Glad to know it worked