Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
QlikWorld, June 24-25, 2020. Free virtual event for DI and DA gurus. Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Contributor III
Contributor III

Expression based on previous row

Hello everyone,

i have this example

DATE                ID      ID2  STATUS

01/01/2016      001    021      D1

13/02/2017      001    022      D1

13/04/2017      001    023      D2


i have made the aggregate by ID and DATE to show the ID by the max(Date) but i want to know if its possible  using only the expression(not script option), get the difference in months between records of the same ID (using DATE).

In simple way, get the difference on months between rows with same ID.

Thanks in advance,

Regards.

1 Solution

Accepted Solutions
Highlighted
Master III
Master III

Re: Expression based on previous row

Hi Paula,

may be this

Alt((Year(DATE)-Above(TOTAL Year(DATE))-1)*12+Month(DATE)+(12-Above(TOTAL Month(DATE))),'Null')

Regards,

Antonio

View solution in original post

4 Replies
Highlighted

Re: Expression based on previous row

Hi,

check above().

can share your required output so that we can help you with better solution.

Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
Highlighted
Contributor III
Contributor III

Re: Expression based on previous row

Hi Prashant,

Above _Function doesn't run well.

i need :

DATE                ID      ID2  STATUS     DIFFERENCE(IN MONTHS)

01/01/2016      001    021      D1          NULL

13/02/2017      001    022      D1          13

13/04/2017      001    023      D2            2

to calculate the difference between rows from DATE field, to records with the same ID.

I hope that helps...

Thanks a lot!

Highlighted
Master III
Master III

Re: Expression based on previous row

Hi Paula,

may be this

Alt((Year(DATE)-Above(TOTAL Year(DATE))-1)*12+Month(DATE)+(12-Above(TOTAL Month(DATE))),'Null')

Regards,

Antonio

View solution in original post

Highlighted
Contributor III
Contributor III

Re: Expression based on previous row

Thank you Antonio!

It runs very well