Difference between today's sales and yesterday's sales

We want to calculate the difference between today's sales and yesterday's sales. How can this be done with a Kibana Painless script within the Kibana user interface?

I think a Lens custom formula combined with a time shift is best--something like sum(field) - sum(field, shift='1d')

Read more about formulas in this blog 10 common Kibana visualization questions answered with formulas and time travel | Elastic Blog and in our documentation: Create visualizations with Lens | Kibana Guide [8.2] | Elastic


Thank you.. this seems to be a good solution. Will try it out and get back

In lens, I performed the following:

Then under metrics, in the right hand side, I added one more reported Inv with time shift of 1 week as shown here:

After adding the time shift field, i get the error on the left that you see in the pic above..

If i were to remove the "top values of SKU" field from the lens, then I get this error:

I need to have both the SKU and the weekend date showing in the report.

the date format has been set in the index as a date with format "Jan 1, 2022 @ 00:00:00.000"
and the SKU is a keyword.

Hello any help with this please

the first error looks like it's not happy with using top values & time shifts. this is because the system isn't sure how to return top values in these cases. you could try to include the SKUs you want as rows manually by using the Filters aggregation as the error suggests (instead of dynamic top values).

the second error looks like a data problem...something with that runtime field you're using for "Weekend Date". it's odd because that date doesn't look wrong. i'm not sure the best way to resolve that

1 Like

Not to inject out of place ... but the date and the expected format do not match that is why there is a parse error, somewhere you need to put in the correct format

1 Like

@ghudgins I think there may be a challenge when using a non-normal @timestamp for a time shift... strangely today I just ran into the same issue when I tried to shift with a month..

1 Like

facepalm it's exactly that. nice catch!

1 Like

Thank you! These insights are very helpful…

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.