Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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!!
javierortiz,
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() )
Regards,
Stefan
javierortiz,
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() )
Regards,
Stefan
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,
Name,
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,
Name,
Num(Num#(Month)) AS Month,
Value
RESIDENT DataTmp;
DROP TABLE DataTmp;
Hope that helps.
Miguel
Yes Stefan, you are right, I tryed that before but I was missing to change the standard format.
Thank you very much!!