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

Announcements
Join us at Qlik Connect 2026 in Orlando, April 13–15: Register Here!
cancel
Showing results for 
Search instead for 
Did you mean: 
jrbrutto
Contributor II
Contributor II

Aritmetic Operation

Hi 

I have the following script with Qlik Sense that works:

Let vDaysn = -7;

SQL SELECT [Field] FROM [dbo].[File] where DateField between DateAdd(DD,$(vDaysn),GETDATE() ) and GETDATE();

I would to make this dynamic introducing an entry field, be able to calculate the related negative in order to use that in SQL statement. Tried the following but it doesn't works:

Let vDays = '=if( $(vDays) = 0,7,$(vDays));

Let vDaysn = '=$(vDays) * -1';

Any suggestion?

Thanks

1 Solution

Accepted Solutions
marcus_sommer

In this way your variables contain only a text - try it in this way:

Let vDaysn = -if($(vDays) = 0,7,$(vDays));

- Marcus

View solution in original post

1 Reply
marcus_sommer

In this way your variables contain only a text - try it in this way:

Let vDaysn = -if($(vDays) = 0,7,$(vDays));

- Marcus