Painless script for inventory of previous week

Hi,
I want to fetch the inventory value of the previous week. Is there a way to write a painless script for this? thanks..

Please provide more information, as it's not clear what you are after here.

How are you storing this inventory? What is the mapping? What are some sample events

Let's say we are tracking week on week inventory of a retailer, every Friday.
The Retailer ended with 200 units of Product-1 in week-1 on 17-Jun. He ended with 300 units of Product-1 in week-2 on 24-Jun. On 24-Jun, I want to run a calculation:

(Week1 ending inventory) - sales = (Week2 ending inventory)
to perform this calculation, i need to fetch prior week (Week1) ending inventory. How can this be achieved? thanks..

I think you'd need to share a document example please.

Hope this helps...

Ok, but that's not in Elasticsearch, so I am not sure how we can work with that sorry.

so are you saying there is no way to script to get previous week inventory value on a current date....?

Not when it's in a spreadsheet like that.

sorry.. the spreadsheet was only for your reference to show the calculation..
let's say a simpler example would be,
I have a file I will upload into Kibana which has only 2 fields, Date and Sales. And all i want to do in Kibana is calculate the difference between sales on 26-Jun and sales on 27-Jun with a runtime field. Is this possible pls?

image

It'd be great if you could please not create multiple topics on the same question. It looks like you have a solution here, so let's close this one - Difference between today's sales and yesterday's sales