Extract Day, Month and year from Today using painless script

Hi Friends,
I am new to the EKL stack. I am trying to calculate MTD sales from data set.
We have three columns

  1. Product Code
  2. Date (dd-MM-yyyy format)
  3. Sales
    All I am trying to do is calculate MTD sales for e.g. If today is 04th of Aug 2021. The code should be able to filter the records from 01st Aug 2021 to 04th Aug 2021 and sum the Sales column. The date which do not fall into the filter condition of MTD should not be considered for the MTD calculation.



Two questions for you. What is MTD sales?
Which chart types did you try? If you look at lens and data table?

For example - here I am looking at logs and bytes. I made a data table for timestamp and bytes sum in lens. And I can look at different time period by using the time picker on top.

Does that help?


Hi Bhavya,

MTD stand for Month to Date. This is a common mertic used for performance monitoring dashboard.

For e.g. If today is 28th July 2021, then the MTD sales metric should give sales from 01st of July 2021 till 28th of July 2021
If today is 15th Aug 2021, then the MTD sales metric should give sales from 01st of Aug 2021 till 15th of Aug 2021.

MTD metric always starts from 01st day of a month of today till today.

Let write a sudo code for reference:
Today (system date ) = 28th Jul 2021
MTD Sales = Sum (All the sales that has occured between 01st of July 2021 till 28th July 2021 inclusing both the start date and end)

Also a pointer, I want to derive the MTD calucation using painless script

Hope this gives better clairfication

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