Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

johnmccdwc
New 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

Tags (1)
1 Solution

Accepted Solutions

Re: Using Today() in set analysis

Can you try this (added double quotes in red)

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

6 Replies
andrespa
Valued Contributor

Re: Using Today() in set analysis

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

MVP
MVP

Re: Using Today() in set analysis

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)

Re: Using Today() in set analysis

Can you try this (added double quotes in red)

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

johnmccdwc
New Contributor

Re: Using Today() in set analysis

Thanks Sunny, this worked

JOhn

johnmccdwc
New Contributor

Re: Using Today() in set analysis

HI Stefan

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

thanks for the reply.

JOhn

MVP
MVP

Re: Using Today() in set analysis

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

Community Browser