Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Now Live: Qlik Sense SaaS Simplified Authoring – Analytics Creation for Everyone: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
tamilarasu
Champion
Champion

Simplify the formula

Hi,

Can any one simplify the formula please.

VDate is a variable and the values can be 201506

=MakeDate( Left(Purgechar(vDate,Chr(39)),4),Right(Purgechar(vDate,Chr(39)),2))

Thank you.

1 Solution

Accepted Solutions
sunny_talwar

This worked for me if you don't need a day:

=Date(Date#(vVar, Chr(39)&'YYYYMM'&Chr(39)), 'MMM-YYYY')

View solution in original post

11 Replies
sunny_talwar

If you just need to convert your variable into a date you can use this:

=Date#(vDate, 'YYYYMM')

But if you need a day as well then you will have a big formula like this:

=MakeDate(Year(Date#(vDate, 'YYYYMM')), Month(Date#(vDate, 'YYYYMM')), 2)

HTH

Best,

Sunny

sunny_talwar

Another look at your formula, why are you purging Chr(39)? You variable doesn't seem to have any single quotes in it?

ankitaag
Partner - Creator III
Partner - Creator III

What is the value in your vDate variable, do you have special characters which you are removing by using purgechar.

tamilarasu
Champion
Champion
Author

I Can't edit variable as it was already created in a application. I just adding an expression in a chart by using this variable.

Sorry actually the variable contains year and month like '201505', so I am using purgechar syntax.

tamilarasu
Champion
Champion
Author

Yes Ankita. The variable contains single quotes at the starting and end of the string.

vikramv
Creator III
Creator III

Sunindia is Right, No need to use purge char,Use like this

=MakeDate( Left('2001/11/11',4),Right('2001/11/11',2))

If your vDate = '2001/11/11'

Thanks,

Vikram.

Not applicable

=Date(MakeDate( Left(vDate,4),Right(vDate,2)),'MMYYYY')

sunny_talwar

This worked for me if you don't need a day:

=Date(Date#(vVar, Chr(39)&'YYYYMM'&Chr(39)), 'MMM-YYYY')

ankitaag
Partner - Creator III
Partner - Creator III

If you want to create the whole date then

=MakeDate(mid($(vDate),1,4),mid($(vDate),5,6),01)

or if you just want YYYY-MM then

=Date(Date#($(vDate),'YYYYMM'),'MM/YYYY')