6 Replies Latest reply: Jun 23, 2016 9:13 AM by Stefan Wühl RSS

    Using Today() in set analysis

    John McCarthy

      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

        • Re: Using Today() in set analysis
          Andres Prado

          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

          • Re: Using Today() in set analysis
            Stefan Wühl

            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
                John McCarthy

                HI Stefan

                 

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

                 

                thanks for the reply.

                 

                JOhn

                  • Re: Using Today() in set analysis
                    Stefan Wühl

                    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

                • Re: Using Today() in set analysis
                  Sunny Talwar

                  Can you try this (added double quotes in red)

                   

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