Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I am new to qlikview. I used nested if conditions in my script. But some of the conditions doesnt work. (Test1 and Test2, mentioned in the script)
Sample:
LOAD Product,
if((Product='Two Wheelers' or Product='Three Wheelers') and Level='Level1','Test3',
if(Product='Two Wheelers','Test1',
if(Product='Three Wheelers','Test2'))) as New_Skill,
Level,
Value
FROM
(ooxml, embedded labels, table is Sheet2);
I know the first condition satisfies , so it not performing the other conditions. But i need Test1 and Test2 in the New_Skill Field.
Please find the attachment and help me sort out this issue.
Regards,
Siva
If I understand you correctly and you need more values per row for the New_Skill field you can use a crosstable load, something like (Also see attached)
Sample:
LOAD Product,
Level,
Value
FROM
[Sample.xlsx]
(ooxml, embedded labels, table is Sheet2);
CrossTable (New_Skill,Product,1) load
RowNo() As Id,
if((Product='Two Wheelers' or Product='Three Wheelers') and Level='Level1',Product) as Test3,
if(Product='Two Wheelers',Product) as Test1,
if(Product='Three Wheelers',Product) as Test2
resident Sample;
IS this what you are expecting?
Please see attached.
Based on your condition and your data, the second and the third condition will never get processed. In order to see "Test1" and "Test2", you should have some Two Wheelers and Three Wheelers with Level other than Level1.
Hi,
Sample:
LOAD Product,
if(Product='Two Wheelers' and Level='Level1','Test3',
if(Product='Three Wheelers' and Level='Level1','Test3',
if(Product='Two Wheelers','Test1',
if(Product='Three Wheelers','Test2')))) as New_Skill,
Level,
Value
FROM
Sample.xlsx
(ooxml, embedded labels, table is Sheet2);
Try the above code.
Please see attached qvw also. To check I have added two rows in your excel.
product_tbl:
LOAD Product,
if(Product='Two Wheelers' and Level='Level1','Test3',
if(Product='Three Wheelers' and Level='Level1','Test3',
if(Product='Two Wheelers','Test1',
if(Product='Three Wheelers','Test2')))) as New_Skill,
Level,
Value
FROM
Sample.xlsx
your expecting output is like this??.
Product | New_Skill | Level | Value |
Four Wjeelers | Level2 | 300 | |
JCB | Level3 | 400 | |
Three Wheelers | Test2 | Level3 | 250 |
Three Wheelers | Test3 | Level1 | 200 |
Two Wheelers | Test1 | Level2 | 150 |
Two Wheelers | Test3 | Level1 | 100 |
if(Product='Two Wheelers' and Level='Level1','Test3',
if(Product='Three Wheelers' and Level='Level1','Test3',
if(Product='Two Wheelers','Test1',
if(Product='Three Wheelers','Test2')))) as New_Skill,
Logically identical to the original post...
See Oleg Troyansky's post
Thanks for your reply. Actually the Linking field here is product. But in my case both tables are linked by two fields.
For Example : ProductID&'-'&CategoryID.
I am not able to bring this key field in the crosstable . I hope you can understand my response.
Regards,
Siva
There's nothing wrong with your script. You just have no data in your source sample that satisfies the conditions for Test2 and Test3.
yes i know there is no data fro Test 2 and Test 3. Actually the Cross table concept is correct. It works. But the problem is , not able to bring the key fields in the cross table.
Regards,
Siva