6 Replies Latest reply: Jul 11, 2016 4:36 PM by Haikuo Yu RSS

    How to get the same date in previous year with Qlik sense

    Haikuo Yu

      We could use function Today() to get the date of today. For example, today is 7/11/2016. We will get 7/11/2016 with function Today().

      How could we get date 7/11/2015 with Qlik time function?

      If we have another day of this year, for example, 2/25/2016.

      How could we get 2/25/2015 (the same date in the previous year) with Qlik time function?

      Thanks so much for your help!

        • Re: How to get the same date in previous year with Qlik sense
          Sunny Talwar

          May be using AddYears() function:

           

          =Date(AddYears(Today(), -1))

            • Re: How to get the same date in previous year with Qlik sense
              Haikuo Yu

              Dear Sunny , thanks so much for your help!

              Could you please give me further help?

              My question is like this:

              I would like to compare myValue in a time series with accumulation, so I use the following as measure.

              The default date range is from the middle of January this year to current date of this year.

                  If(GetSelectedCount(myDate),

                      RangeSum ( above ( Sum(myValue) , 0 , RowNo() ) ) ,

                     

                      RangeSum ( above ( Sum({< myDate *= {">1/16/2016" } >} myValue) , 0 , RowNo() ) )

                 

                   )

              I would like to compare the accumulation myValue in the same date range of previous year, so I add another measure. It will be something as:

                  If(GetSelectedCount(myDate),

                      RangeSum ( above ( Sum(myValue) , 0 , RowNo() ) ) ,

                     

                      RangeSum ( above ( Sum({< myDate *= {">1/16/2015 < Date(AddYears(Today(), -1))" } >} myValue) , 0 , RowNo() ) )

                 

                   )

                

              Firstly, is my above expression correct?

              Secondly, how to get 1/16/2015 from 1/16/2016 with a time function? If I directly type 1/16/2015, it will be hard coding. I would like to be dynamic.

              Thanks again!