3 Replies Latest reply: May 29, 2012 1:04 PM by javierortiz RSS

    How can I get the current month in a cross table???

      Hi all, how can I get the current month (MAY) if I have a cross table???


      the fields I crossed are the months.


      I attached the app for a better understand, Thank you all!!

        • How can I get the current month in a cross table???
          Stefan Wühl



          your sample app shows no data at all in the model, could you recheck this?


          You defined your variable like

          let vCurrent_Month = Num(MonthStart(Peek(today(),0,today())));


          What do you want to achieve with this (especially with the peek() function)?


          I would suggest to use

          let vCurrent_Month = Month(Today());


          Your Month names you are retrieving from your table must match the standard format of your month you set in

          SET MonthNames='ene;feb;mar;abr;may;jun;jul;ago;sep;oct;nov;dic';


          assure that also the cases match (or use some of the string functions to assure that during load, like capitalize() )




          • Re: How can I get the current month in a cross table???
            Miguel Angel Baeyens de Arce

            Hi Javier,


            Check the following sample script. What is happening is that the actual Month value in QlikView needs to be numeric, and CROSSTABLE does fill the name of the month but with a text (non-numeric) value. This should give you an idea on how to achieve what you are looking for. You have to do loads because CROSSTABLE does not allow preceding loads.


            DataTmp: // original source of data, INLINE in the example 
            CROSSTABLE (Month, Value, 2) LOAD Code,
                      Ene AS 1,
                      Feb AS 2,
                      Mar AS 3,
                      Abr AS 4,
                      May AS 5,
                      Jun AS 6,
                      Jul AS 7,
                      Ago AS 8,
                      Sep AS 9,
                      Oct AS 10,
                      Nov AS 11,
                      Dic AS 12 
            INLINE [
            Code, Name, Ene, Feb, Mar, Abr, May, Jun, Jul, Ago, Sep, Oct, Nov, Dic
            A, 1, 10, 100, 101, 110, 10, 100, 101, 110, 10, 100, 101, 110
            Data: // Now Month has a numeric value that can be linked to a calendar
            LOAD Code,
                      Num(Num#(Month)) AS Month,
            RESIDENT DataTmp;
            DROP TABLE DataTmp;


            Hope that helps.