Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
libinanto95
Contributor
Contributor

Previous Data

Hey Folks,

 

I have a requirement as if the Current Year from ( Year table as from 2011 to 2019) and Current Month Data is not available on the particular field then I have the take the value from the previous month table, 

Assume that if i have a value on Oct 2018 and till Jun 2019 I have no value in between tables. So How should i apply logic in this case.

I need the Oct 2018 Value should be displayed on Jun 2019 field...

So how should I perform

 

Thanks in advance...!!!

6 Replies
rubenmarin

Hi, using peek() or previous() you can access to last record loaded, for this you need a sorted load, ie:

LOAD KeyFields,

Date,

If(Conditions, Value, Peek(Value)) as Value // If conditions are true load Value, else loads the Value of the last record

From/Resident...

Order By KeyFields, Date;

libinanto95
Contributor
Contributor
Author

Thanks for your reply but i tried using your function still i cant fetch the data from the table table.

rubenmarin

Can you post a sample to show what are you trying to do?

libinanto95
Contributor
Contributor
Author

I need the Oct 2018 Value should be displayed on Jun 2019 field...

So how should I perform

 

My Exact Data is:

Load

Values, Month, Year

0.001, Jun , 2016

0.002, Jul, 2016

0.003, Aug, 2016

0     ,  Oct, 2016

0     ,  Nov, 2016

0     ,  Dec, 2016

0     ,  Jan, 2017

0     ,  Feb, 2017

0     ,  Mar, 2017

0     ,  Apr, 2017

0     ,  May, 2017

0     ,  Jun, 2017

 

Now I need the Value of Aug, 2016 as my Current month Value as my Current Month is Jun, 2017.

Now is my Question Clear?

rubenmarin

Sample attached.

1- Original data creating date

2- Sorted load to propagate last value till last month

3- Load sorted descendent, if value of the first row (most recent date) is zero it takes the propagated value.

Brett_Bleess
Former Employee
Former Employee

Anto, did Ruben's final example do the trick for you?  If so, please consider clicking the Accept as Solution button on that post to give him credit for the help and to let everyone else know that worked.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.