Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
johnmccdwc
Contributor
Contributor

Using Today() in set analysis

I want to show a running total for 'Today' in a model.

The following works (when i hard code the date)

=sum({$<CurYTDFlag = {1},LineType = {2},ShipDate={'22/06/2016'}>} NetDelQty)

but when i try to use Today i cannot get it to fly:

=sum({$<CurYTDFlag = {1},LineType = {2},ShipDate={$(=Date(today(),'DD/MM/YYYY'))}>} NetDelQty)

ANy ideas?

John

1 Solution

Accepted Solutions
sunny_talwar

Can you try this (added double quotes in red)

=Sum({$<CurYTDFlag = {1}, LineType = {2}, ShipDate = {"$(=Date(Today(), 'DD/MM/YYYY'))"}>} NetDelQty)

View solution in original post

6 Replies
andrespa
Specialist
Specialist

Hi John, did you try to put it into a variable and the put the variable in the set analysis?

Hope it helps,

Andrés

swuehl
MVP
MVP

Where are you using this expression? In a chart?

Then put it into e.g. a straight table chart's expression and leave the expression label empty.

Then hover with the mouse over the expression header in the table chart.

You should see your expression with the dollar sign expansion evaluated and replaced.

What do you see?

I can only think of two possible differences right now between the two expressions:

a) Missing single quotes in the second expression around the dollar sign expansion:

=sum({$<CurYTDFlag = {1},LineType = {2},ShipDate={'$(=Date(today(),'DD/MM/YYYY'))'}>} NetDelQty)


b) today() may not return '22/06/2016', because the default timer mode is returning the date when your QVW was opened.

See the help for available timer modes (0 to 2).

=sum({$<CurYTDFlag = {1},LineType = {2},ShipDate={'$(=Date(today(1),'DD/MM/YYYY'))'}>} NetDelQty)

sunny_talwar

Can you try this (added double quotes in red)

=Sum({$<CurYTDFlag = {1}, LineType = {2}, ShipDate = {"$(=Date(Today(), 'DD/MM/YYYY'))"}>} NetDelQty)

johnmccdwc
Contributor
Contributor
Author

Thanks Sunny, this worked

JOhn

johnmccdwc
Contributor
Contributor
Author

HI Stefan

interestingly this seems to work but the Syntax checker doesn't like it

thanks for the reply.

JOhn

swuehl
MVP
MVP

Right, the syntax checker is not really able to understand that the dollar sign expansion is actually evaluated and replaced before the expression is parsed. So it might indicate an error here.

I still prefer to use single quotes for literals and double quotes for searches, though both should work the same in current QV software (there is a note by HIC in one of his blog posts that these quotings should be handled differently, but apparently they won't fix it (and this will break a lot of people's stuff)).

Regards,

Stefan