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: 
mario-sarkis
Creator II
Creator II

Year Month

Hey ALL,

I have a field Year_Month looks like:

Year_Month

201311

201312

201401

201402

201403

201404

201405

201406

201407

201408

201409

201410

201411

201412

201501

201502

201503

201504

201505

201506

201507

201508

201509

201510

201511

201512

if i want to to calculate one year back ei. if i have 201512 i need to see the value ok 201412 what function should i use.

Thank you,

8 Replies
sunny_talwar

Can you elaborate of where exactly are you trying to do it? In script? straight table?

Mark_Little
Luminary
Luminary

Hi

You could try something like

LEFT(GetFieldSelections(Year_Month),4) -1 & Right(GetFieldSelections(Year_Month),2)

Mark

Anonymous
Not applicable

sunny_talwar

I agree that AddMonths or AddYears is the way to go. But where are we doing this? How can we recommend anything before knowing that

Anonymous
Not applicable

Sunny agreed with you. He asked for function what function should i use.

And I told him same with some examples

mario-sarkis
Creator II
Creator II
Author

hey sunny   i need to use this in the Set analysis part :

Year_Month={">=one year back <=max Year_Month"}>}

Thank you

sunny_talwar

Assuming Year_Month is a date field, may be this:

{<Year_Month = {"$(='>='& Date(AddYears(Max(Year_Month), -1), 'YYYYMM') & '<=' & Date(Max(Year_Month), 'YYYYMM'))"}>}

HirisH_V7
Master
Master

Hi ,

Check this ,

Temp:

LOAD * ,

If(Mid(Year_Month,1,4),'2014',2015) as Year,

Mid(Year_Month,5,6) as Month

INLINE [

Year_Month

201311

201312

201401

201402

201403

201404

201405

201406

201407

201408

201409

201410

201411

201412

201501

201502

201503

201504

201505

201506

201507

201508

201509

201510

201511

201512

];

Data:

Load Year&Month as [Year-Month]

Resident Temp;

output:

yearmonth.PNG

HTH,

Hirish

HirisH
“Aspire to Inspire before we Expire!”