Skip to main content
Announcements
Customer Spotlight: Discover what’s possible with embedded analytics Oct. 16 at 10:00 AM ET: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Dayna
Creator II
Creator II

Referencing a previous record

Hello All,

I'm hoping that you can help me, I need to reference data from a previous record. What I have is a data source set up as:

Product Date Amount

And what I want to do, is show a data range (From and To), show for each record, the date to is the date in the row and the date from is the previous date for the same product/site/domain.

I've created a basic test app to show you what I mean. I hope you can help me!

Kind Regards,
Dayna

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hello Dayna,

If possible I'd create taht in the script, something like

Data:LOAD Product, Date(Date) AS DateTo, If(Product = Previous(Product), Previous(Date), 'n/a') AS DateFrom, AmountFROM FileORDER BY Product, Date; // Data source


Hope that helps.

EDIT: Checked "Previous(Date) as DateFrom", my fault.

View solution in original post

4 Replies
Miguel_Angel_Baeyens

Hello Dayna,

If possible I'd create taht in the script, something like

Data:LOAD Product, Date(Date) AS DateTo, If(Product = Previous(Product), Previous(Date), 'n/a') AS DateFrom, AmountFROM FileORDER BY Product, Date; // Data source


Hope that helps.

EDIT: Checked "Previous(Date) as DateFrom", my fault.

Dayna
Creator II
Creator II
Author

Hello Miguel,

Many thanks for your response, I tried it on my script and I get the below which puts the same date in both fields rather than the previous date.

Kind Regards,
Dayna

Miguel_Angel_Baeyens

Yep, I noted after posted I missed a Previous(Date) (obviously) in the script. I corrected it above.

Dayna
Creator II
Creator II
Author

Thought that was the case! Looks good! Hope it can work when my app gets more complex!

Many thanks Miguel!