Hello,
As the following image show i am trying to calculate 4 things with timelion.
-
number of orders in my erp
-
numbers of orders in my erp one week ago
-
the difference between previous numbers 1 and 2
-
to show the same difference also as a percentage.
Steps 1,2,3 work fine. Nevertheless step 4 doesn't work.
The code that i use for each step respectively is the following:
.es(index=connect-*, q='order_type:order and event_type.keyword:order').label('Orders AX'),
.es(index=connect-*, q='order_type:order and event_type.keyword:order',offset=-1w).label('1 week ago'),
.es(index=connect-*, q='order_type:order and event_type.keyword:order').subtract(.es(index=connect-*, q='order_type:order and event_type.keyword:order',offset=-1w)).label("Difference previous week"),
.es(index=connect-*, q='order_type:order and event_type.keyword:order').subtract(.es(index=connect-*, q='order_type:order and event_type.keyword:order',offset=-1w)).divide(.es(index=connect-*, q='order_type:order and event_type.keyword:order')).label('Difference with previous week in Percentage')
What shall i correct in step 4 so i can also see the difference in percentage correctly?
Hi @Alexandros888,
Could you try adding it to your 4th script before .label:
.multiply(100).yaxis(units="custom::%")
Regards, Dzmitry
Hello
Thank you for your quick response.
I tried your change like that:
.es(index=connect-*, q='order_type:order and event_type.keyword:order').label('Orders AX'),
.es(index=connect-*, q='order_type:order and event_type.keyword:order',offset=-1w).label('1 week ago'),
.es(index=connect-*, q='order_type:order and event_type.keyword:order').subtract(.es(index=connect-*, q='order_type:order and event_type.keyword:order',offset=-1w)).label("Difference previous week"),
.es(index=connect-*, q='order_type:order and event_type.keyword:order').subtract(.es(index=connect-*, q='order_type:order and event_type.keyword:order',offset=-1w)).divide(.es(index=connect-*, q='order_type:order and event_type.keyword:order')).multiply(100).yaxis(units="custom::%").label('Difference with previous week in Percentage')
Unfortunately now it shows everything in percentage
i want only the fourth section in percentage
@Alexandros888,
Since you have a mix of absolute and percentage values, try just using
.multiply(100)
It should fix the data.
Regards, Dzmitry
Hello Dzmitry,
As you said i changed it like that:
.es(index=connect-*, q='order_type:order and event_type.keyword:order').subtract(.es(index=connect-*, q='order_type:order and event_type.keyword:order',offset=-1w)).divide(.es(index=connect-*, q='order_type:order and event_type.keyword:order')).multiply(100).label("Difference previous week in Percentage %")
and it worked 
Thank you very much !!!!