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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

variable mixed in set analysis

Im a new user of QV, i hope you solve this problem

How do I get and expression for previous day?

I have sales from a period and use set analysis to select certain group of salesman

In the same table y need to shown the sales of yesterday, for these group of salesman.

Sum({<[CLASE DE VENDEDOR]={'NACIONALES'}, DATE=VDIAANTERIOR>}Ventas)

the variable = VDIAANTERIOR=Date(Now()-1)

This doesnt work.

HELP PLEASE.

How do I get an expression for previous month sales?

1 Reply
johnw
Champion III
Champion III

I believe like this:

Sum({<[CLASE DE VENDEDOR]={'NACIONALES'}, DATE={'$(VDIAANTERIOR)'}>}Ventas)

WARNING:  Using now() in a chart like this is dangerous.  In its default mode, now() updates every second.  That means your chart must be recalculated every second.  If it takes a second or more to calculate this chart, it will max out your CPU time.  Also realize that now() returns a timestamp, not a date.  While the date() function will format it as a date, and my changes above will then ignore the time portion, the time portion still exists.  You could do floor(now(2)), but you might as well just use the today() function.  The default mode of the today() function is also CPU friendly, in that it only checks the date when the document is opened.  What I would do is skip the variable completely, and code it like this:

sum({<[CLASE DE VENDEDOR]={'NACIONALES'}, DATE={'$(=date(today()-1))'}>} Ventas)