Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all ,
swuehl,M G,Peter Cammaert,jagan mohan rao appala,Marco Wedel
How to change the below if statements to case statements?
Anyone help me on this.
If(MATCH_TYPE='VOD', 'Tier 1',
If(NOT MATCH_TYPE(NETWORK_TYPE,'Broadcast','Cable') AND NOT IsNull(PROGRAM_NAME),
If(Num#(Left(TIMESHIFT_INDICATOR_ID,2)) >= 10 AND Num(Left(TIMESHIFT_INDICATOR_ID,2)) <= 16
AND Count(Distinct USERS_META_ID) <> 0,'Tier 2','Tier 1')
)
) as Field_name
if(MATCH_TYPE = 'VOD','Tier 1',
if(MATCH_TYPE <> 'VOD' AND NETWORK_TYPE IN ('Broadcast', 'Cable') AND PROGRAM_NAME <> null,
if(TIMESHIFT_INDICATOR_ID = 10 AND SAMPLE <> 0,
if(TIMESHIFT_INDICATOR_ID = 11 AND SAMPLE <> 0,
if(TIMESHIFT_INDICATOR_ID = 12 AND SAMPLE <> 0,
if(TIMESHIFT_INDICATOR_ID = 13 AND SAMPLE <> 0,
if(TIMESHIFT_INDICATOR_ID = 14 AND SAMPLE <> 0,
if(TIMESHIFT_INDICATOR_ID = 15 AND SAMPLE <> 0,
if(TIMESHIFT_INDICATOR_ID = 16 AND SAMPLE <> 0,'Tier 2','Tier 1')))))))))
as field_name
Message was edited by: suri qv
Hi Suresh,
Qlikview have "switch case" function. You can find it in Help.
It might be helpful.
Regards
KC
thnx KC will look into that till i get any updates frm experts.
thnx fr reply raj... wil chk nd update u if it wrks r nt.
In QlikView script, SWITCH... CASE is a control statement that is to be used outside of other statements like LOAD etc...
LOAD statements only accept functions, like IF() (this is a function, not a statement, although there is an IF control statement as well).
In a LOAD statement, you can use a Pick/Match combo to simplify IFs that test for individual values. In your last example, the last part is pretty useless because IMHO it tests for TIMESHIFT_INDICATOR_ID being equal to 10 AND 11 AND 12 AND 13..., all at the same time, which is obviously never the case. However, if you want to check whether a field is within a range of consecutive numerical values, do like:
:
IF ((TIMESHIFT_INDICATOR_ID >= 10) AND (TIMESHIFT_INDICATOR_ID <= 16) AND (SAMPLE <> 0),
'Tier 2','Tier 1')
Best,
Peter
Hi,
Case statement cannot be applied in Load statement, it should be applied outside Load statement like FOR, WHILE etc.
Regards,
Jagan.
Example from Qlikview help file.
Examples:
switch I
case 1
load '$(I): CASE 1' as case autogenerate 1;
case 2
load '$(I): CASE 2' as case autogenerate 1;
default
load '$(I): DEFAULT' as case autogenerate 1;
end switch
thnx jagan,and pcammaert
will try both of ur logic..
Hi,
You can fine tune this by
If(MATCH_TYPE = 'VOD','Tier 1',
If(MATCH_TYPE <> 'VOD' AND Match(NETWORK_TYPE, 'Broadcast', 'Cable') AND PROGRAM_NAME <>null,
AND SAMPLE <> 0 AND MATCH(TIMESHIFT_INDICATOR_ID, 10, 12, 13, 14, 15, 16), 'Tier 2', 'Tier 1'))
as field_name
Hope this helps you.
Regards,
jagan.
And one more info is...
if am usng with in Select statment not in load statmnt.
am usng inside Select statmnt how shud i write this query?
If(MATCH_TYPE='VOD', 'Tier 1',
If(NOT MATCH_TYPE(NETWORK_TYPE,'Broadcast','Cable') AND NOT IsNull(PROGRAM_NAME),
If(Num#(Left(TIMESHIFT_INDICATOR_ID,2)) >= 10 AND Num(Left(TIMESHIFT_INDICATOR_ID,2)) <= 16
AND Count(Distinct USERS_META_ID) <> 0,'Tier 2','Tier 1')
)
) as Field_name
hi jagan.
This is not inside the load stmnt . it is related select stmnt. wit in that how can i write?