Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Need help on Month & Date

I'm new to qlikview and need your help in the below scenario.

I have a date field "Field1" with normal dates.   ( say from jan 1 2008 to current date in dd/mm/yyyy format )

Now i want a month filed "Field2" out of this dates .. condition is dates from 26th of every month to 25th of next month should be grouped as a month .. any suggestions will be greatly helpful !

Labels (1)
1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Use script like this when loading you calendar (adapt field names to your requirements):

Calendar:

LOAD Date,

  Month(Date) As CalendarMonth,

  Month(If(Day(Date) <= 25, Date, AddMonths(Date, 1))) As FiscalMonth,

  ...

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

12 Replies
amit_saini
Master III
Master III

Venkat,

You can create two Month variable like vMonthStart and vMonthEnd and assign them desired range values.

Thanks,
AS

MarcoWedel
MVP
MVP

MonthName(Field1 - 25) as Field2

regards

Marco

Not applicable
Author

Amit,

         As i said , i'm new to qv. Can you please elaborate.

My requirement is , for e.g if a user selects any date between "26 jan" to "25 feb"  if should come user accounting month ( filed name) Feb,  if he selects accounting month march all dates from 26 feb to 25 march should be considered

amit_saini
Master III
Master III

Venkat,

Understand !

Could you please share your source file or application .

Thanks,

AS

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Use script like this when loading you calendar (adapt field names to your requirements):

Calendar:

LOAD Date,

  Month(Date) As CalendarMonth,

  Month(If(Day(Date) <= 25, Date, AddMonths(Date, 1))) As FiscalMonth,

  ...

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Amit,

         Thank you for the help .. Jonathan trick has solved my problem

Not applicable
Author

Marco,

          Results were a bit different that i expected.. i get results from feb 26 to march 25 when i select  feb .. what i really want is jan26 to feb 25 when i select feb.. useful suggestion though , can be used for other requirements 😉

Not applicable
Author

Jonathan,

              It worked like a charm .. Thank you very much 🙂

MarcoWedel
MVP
MVP

that's a static offset which can be corrected like (without the need for any potentially time consuming conditions):

MonthName(Field1 - 25, 1) as Field2

one sample app:

table1:

LOAD *,

     MonthName(Field1 - 25, 1) as Field2;

LOAD

  Date(Date#('01/01/2008', 'MM/DD/YYYY')+IterNo()-1, 'MM/DD/YYYY') as Field1

AutoGenerate 1

While Date#('01/01/2008', 'MM/DD/YYYY')+IterNo()-1 <= Today();

QlikCommunity_Thread_127830_Pic1.JPG.jpg

hope this helps also

regards

Marco