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

If problem

Hi,

2 weeks old into QV, and trying to get on board with the basics.

I have data in columns, SalesID, LA, LP, VO. There are basically 2 values on columns LA,LP, VO, either 1 or 0. I would like to create a 5th column that checks that if there is 0 on any of the columns in the row, then the new row value is 1, otherwise it is 0.

if((LAr or VO or LP) = 0, 0, 1) as VR. This however doesn't work.

After this would like to create 4 new tables.

SalesID, LA =1

SalesID, VO =

SalesID, LP =1

SalesID, VR =1

Help on this much appreciated...

12 Replies
MK_QSL
MVP
MVP

Try

IF(LA&LP&VO = 000, 0, 1) as VR


UPDATE : My mistake in previous reply. I overlooked your requirements. I thought you want VR = 0 if all LA, LP and VO are 0...

you can use below...


Temp:

Load * Inline

[

  SalesID, LA, LP, VO

  A, 0,0,1

  B, 0,1,0

  C, 0,0,1

  D, 0,0,0

  E, 0,1,1

  F, 1,1,1

];

NoConcatenate

FINAL:

Load

  SalesID,

  IF(LA= 0 or LP = 0 or VO = 0,0,1) as VR

Resident Temp;

alexandros17
Partner - Champion III
Partner - Champion III

the sysntax is:

if(LAr=0 or VO=0 or LP=0, 0, 1) as VR

its_anandrjs

Write like

If ( LA = 0 OR VO = 0 OR LP = 0, 1, 0) as VR


Hope this helps

Not applicable
Author

cheers but this didn't work since I was looking that if any of the columns have a different value and not that if all of them have 0  values.

Not applicable
Author

Thanks. Works like a charm

MK_QSL
MVP
MVP

Check my second solution...

its_anandrjs

Or you can add this in your load statement like

If ( (LA = 0 OR VO = 0 OR LP = 0), 1, 0) as VR




Hope this helps

Not applicable
Author

Hi again,

The above was a 2 part question, sorry for the unclarity. So part 2, how would I then create for tables where:

SalesID, LA = only 1

SalesID, VO =only 1

SalesID, LP =only 1

SalesID, VR =only 1

Not applicable
Author

both work Anand. cheers