Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
andreyfcdk91
New Contributor III

First date from YearMonth field

Good day!

Is any way to get first date for every YearMonth?

In model i have only one period field YearMonth

I need to get such values:

YearMonth     Date

201401     01.01.2014

201402     01.02.2014

201507     01.07.2015

....

Thanks.

11 Replies
neetha_p
Honored Contributor

Re: First date from YearMonth field

use monthstart function

Not applicable

Re: First date from YearMonth field


try this:


MakeDate(Year, Month, 1) as Date

andreyfcdk91
New Contributor III

Re: First date from YearMonth field

MonthStart(YearMonth) as Date?

it's working incorrectly

Re: First date from YearMonth field

Try this in the front end:

=Date(MakeDate(Year(Date#(YearMonth, 'YYYYMM')), Month(Date#(YearMonth, 'YYYYMM')), 1), 'DD.MM.YYYY')

or this in the back end:


Date(MakeDate(Year(Date#(YearMonth, 'YYYYMM')), Month(Date#(YearMonth, 'YYYYMM')), 1), 'DD.MM.YYYY') as Date

sasiparupudi1
Honored Contributor III

Re: First date from YearMonth field

=Date(monthstart(date#(YearMonth,'YYYYMM')),'DD.MM.YYYY')

neetha_p
Honored Contributor

Re: First date from YearMonth field

use makedate function

MVP
MVP

Re: First date from YearMonth field

=MonthStart(Date#(YourMonthYearField,'YYYYMM'))

andreyfcdk91
New Contributor III

Re: First date from YearMonth field

Thank you!!!

Could you please write me, how to write flags:

1. YTD (from beginning of current year till max yera month)

2. PriorYTD (The same as YTD, but for prior year)

3. MTD (get max YearMonth)

4. PriorMTD (The same as MTD, but for prior year)

Re: First date from YearMonth field

YeartoDate(TempDate)*-1 as CurYTDFlag, 

YeartoDate(TempDate,-1)*-1 as LastYTDFlag,

If(TempDate >= MonthStart(Today()) and TempDate <= Today(), 1, 0) as CurMTDFlag,

If(TempDate >= AddYears(MonthStart(Today()), -1) and TempDate <= AddYears(Today(), -1), 1, 0) as LastMTDFlag,

Community Browser