Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Dynamic update statement

Hello everybody.

In my loading script, I loaded, among the others, two fields (see them in the script below):

IncrementalLoadPreventivi:

LOAD ...,

    Num(0) AS "Status",

    ...,

   NUM([NUMERO PREVENTIVO]) AS "Numero preventivo",

    ...

FROM

...

The field 'Status' can be either 0 or 1 and is set by default to 0.

I defined the variable 'vNumeroPreventivo' that I can set in an Input table.

I want to be able to switch the value of Status, between 0 and 1, for the record where [NUMERO PREVENTIVO] = $(vNumeroPreventivo).

Therefore I created a button with a Dynamic update action. Te following is the statement I use:

UPDATE *

  SET Status = 1 - Status

  Where [Numero preventivo] = $(vNumeroPreventivo);

The statement doesn't work.

I have to change it like the following:

UPDATE *

  SET Status = 1

  Where [Numero preventivo] = $(vNumeroPreventivo);

or

UPDATE *

  SET Status = 0

  Where [Numero preventivo] = $(vNumeroPreventivo);

The last two statements work, but those don't allow me to automatically switch the value (every time I have to update the statement.

I need a statement that allows me to switch between 0 and 1.

I'm using a personal edition of QV11, so please don't post qvw files.

Regards,

Nicolò.

Messaggio modificato da Nicolò Antonietti Added the version of my QlikView.

Labels (1)
1 Solution

Accepted Solutions
swuehl
Champion III
Champion III

You should be able to use a statement like

=If( only({<[Numero preventivo] = {$(vNumeroPreventivo)}>} Status),

'UPDATE *

  SET Status = 0

  Where [Numero preventivo] = $(vNumeroPreventivo);'

  ,

'UPDATE *

  SET Status = 1

  Where [Numero preventivo] = $(vNumeroPreventivo);'

  )

View solution in original post

2 Replies
swuehl
Champion III
Champion III

You should be able to use a statement like

=If( only({<[Numero preventivo] = {$(vNumeroPreventivo)}>} Status),

'UPDATE *

  SET Status = 0

  Where [Numero preventivo] = $(vNumeroPreventivo);'

  ,

'UPDATE *

  SET Status = 1

  Where [Numero preventivo] = $(vNumeroPreventivo);'

  )

Not applicable
Author

Thank you, Swuehl, for your quick reply.

It's working perfectly fine.

Nicolò.