4 Replies Latest reply: Jul 1, 2013 4:01 AM by sarah_mader RSS

    Get Date of Max value

      Hi,

       

      i try to find the date when the max value occures.

       

      Example table:

      CarDatePrice
      BMW01-05-20012345,00
      VW03-05-20011555,00
      BMW25-07-20044533,99
      VW19-04-20032999,99
      BMW02-12-20054999,99

       

      First i have to say my table is animated.

      Means i use Max({<Date={'<=$(currentDate)'}>}Price) in Expression.

       

      currentDate is a variable, with changes every second.

       

      Now i want to find the linked date, when the max Price occurres.

       

      I tried:

       

      FieldValue('Date',FieldIndex('Price',Max({<Date={'<=$(currentDate)'}>}Price)))

       

       

      but it's not working...

      Any ideas?

      Thx

      Sarah

        • Re: Get Date of Max value
          Deepak Vadithala

          Hi Sarah,

           

          Have you tried using FirstSortedValue()? This will fetch the Date for the Max Price value.

           

          Firstsortedvalue(DISTINCT Value, Date)

           

           

          I've created video tutorial on my blog. Please check this link...

           

          http://qlikshare.com/392

           

          I hope this helps! BTW - I'd recommend using animated/Now() functions in the dashboard. It might work okay but there will be constant CPU overhead. I'm sure you're aware of this.

           

          Good luck!

           

          Cheers,

          DV


           


            • Re: Get Date of Max value

              Thx for the reply!

               

              Yes,  FirstSortedValue(distinct Date, -Price) solves the problem.

              Very nice and compact function!

               

              Also some very informative movies:)

               

              I'm happy that u understand how to animate with now()-function, so i have to use this chance to ask some questions about the experience with "self-animated" charts^^

              What do u mean with constant CPU overhead?

              I know that the animation needs more CPU than normal charts, but not in an damaging amount...

              Do u think, that animating with the now()-function should be avoided?

              Or is it a question of performance?

                • Re: Get Date of Max value
                  Deepak Vadithala

                  Hi Sarah,

                   

                  I'm glad you solved it by using FirstSortedValue() function. It's one my favourite function in QlikView.

                   

                  I did some animations using Now() to show stock live in a store. I.e showing/hiding images based on time and using source data of current available stock. It works fine but if you have massive application with loads of calculations then it will bring down the peformance & user experience. As you understand that QlikView caches all the calculations until Working Set Limits are reached. So performing calculations every second may not be a good idea if you have complex calculations or variables.

                   

                  It's not recommended but it doesn't matter if it's simple application and if it's already working fine. Probably you should come up with mathematical approach of calculating once every few minute instead of every second.

                   

                  Good luck!

                   

                  Cheers,

                  DV

                   

                  www.QlikShare.com