Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
bsbernabe
Creator
Creator

Variable for the fields of Month & Year only

Hello There

I have a project where the date of the data was only the month and year so I'm trying to make a variable like this   =MonthStart(MakeDate(T_Year,T_Month,1)) but just happen is not working, Is there any way to make a variable for this month and year?

Best Regards,

Bing

1 Solution

Accepted Solutions
sunny_talwar

Where are you trying to do this? In the script?

This should have worked

LOAD Date(MakeDate(T_Year, T_Month, 1)) as T_Date,

          T_Year,

          T_Month

          ...

FROM ....;

Now if you T_Month is like Jan, Feb, Mar, then QlikView won't recognize them as Month, unless you help it recognize it as date. In this case, try this


LOAD Date(MakeDate(T_Year, Month(Date#(T_Month, 'MMM')), 1)) as T_Date,

          T_Year,

          T_Month

          ...

FROM ....;

The Date#() function will help interpret the T_Month's value of Jan, Feb , Mar as a date and Month will extract the Month/Month Number for it to be used in the MakeDate() function.

HTH

Best,

Sunny

View solution in original post

7 Replies
Anil_Babu_Samineni

May be use this?

=MonthStart(MakeDate(2017, 02, 1))


Or


MonthStart(MakeDate(Year, Month, 1))


Or


MonthStart(MakeDate(GetFieldSelections(Year), GetFieldSelections(Month), 1))


Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
sunny_talwar

Where are you trying to do this? In the script?

This should have worked

LOAD Date(MakeDate(T_Year, T_Month, 1)) as T_Date,

          T_Year,

          T_Month

          ...

FROM ....;

Now if you T_Month is like Jan, Feb, Mar, then QlikView won't recognize them as Month, unless you help it recognize it as date. In this case, try this


LOAD Date(MakeDate(T_Year, Month(Date#(T_Month, 'MMM')), 1)) as T_Date,

          T_Year,

          T_Month

          ...

FROM ....;

The Date#() function will help interpret the T_Month's value of Jan, Feb , Mar as a date and Month will extract the Month/Month Number for it to be used in the MakeDate() function.

HTH

Best,

Sunny

bsbernabe
Creator
Creator
Author

Hi Thank you so much for your support but i already use that and it not working but any thank you again.

Regards

Bing

bsbernabe
Creator
Creator
Author

Hello Sunny

thank you for your time i try to reload this Date(MakeDate(T_Year, Month(Date#(T_Month, 'MMM')), 1)) as T_Date and its working ,if ever i make a variable is it possible?

Thanks Bing

sunny_talwar

‌Make a variable? what do you mean? Not sure I underatand

bsbernabe
Creator
Creator
Author

Hey Sunny your script is work it its great, so what i am trying to say in make a variables at variable overview cause i try but its not working  like this:

vTargetCussMonth =Date(MakeDate([T_Year], Month(Date#([T_Month], 'MMM')), 1))

Any way thanks

sunny_talwar

Does this need to be the Max or Min? I guess I am hoping that you are looking to store a single value in this variable? or are you going to be using this in a chart? What exactly is this variable needed for?