Canvas time filter

I made a Canvas workpad showing one metric. I need dynamic filters and if I import a filter from the dashboard they seem to have no effect.
When I add a time filter from canvas "add element" my metric says "Error cannot divide by 0"
Where can I find configuration for the filters?
How do I attach them to the metrics (and charts)? Do they all need to be attached separetly?

In Canvas you have two dynamic filters.
For is for the time. And one is for specific field values called the dropdown filter.
If you just add those, each visualization and metric will get effected.. also from other slides. But you can define filter groups. A Filter group usually has a couple of filters + corresponding visualizations.

You see devide by zero most likely because your metric is based on a calculation. Maybe the number of rows that can be zero for the given time interval.

Yes it is based on calculation. However, I tried with all time. ie. many years back so it cannot be completely zero

I'm trying to implement another filter too and I think I knw where the issue is.
In my calculations I use two different indecies. Now when I make a fillter it filters on both of them, But it should only filter on the first essql value in my calculation.

Can you help me achieve this please? If I somehow wrap everything in an if statement and the filter adds there the value or something. Changing the global variables or something?

I can try to help, but need a bit more context.
How is your expression incl. the calculation look like? Which filters are on the board?
Whats the overall use case you would like to achive and so on.
Of you need more examples you can look into Kibana dashboard and canvas gallery

Time filter is one issue that I am skipping perhaps.
How ever I am trying the other issue now.
How do I put a global variable inside the query
The code below works, but I need to use variable instead of hard coded "id" ("abc")

and on top of that I need to use global variable set in the UI and not in the expression editor.
If not possible then I can use the drop down for this. but atm I do not know how to exchange this for that either

| var_set name="id" value="abc"
| var_set name="myvar" value={filters | essql query="SELECT COUNT(customer._id) AS buyers FROM \"visitors*\" WHERE ( = 'abc' " }
| math 
  {string "visitors/" {filters | var "myvar" | math "sum(buyers)"}}

For the query parameter you open a new expression using curly brackets and in this expression you define the string including the query and the variable.

Here you have a couple of examples

ok, thanks. I will check. I would prefer not to upload anything. But since googling for snippets and examples bear no fruit, I do appreciate this.

This is from the example:

var_set "row" value=1

| filters

  | essql query="SELECT, Replace(, ' ' , '%20') as appNameURL FROM \"apm*\" where is not null group by"

  | var_set "appName" value={if condition={rowCount | gt {var "row"}} then={getCell row={var "row"} column=""} else={string ""}}

  | var_set "appNameURL" value={if condition={rowCount | gt {var "row"}} then={getCell row={var "row"} column="appNameURL"} else={string ""}}

| filters

  | essql query={string "SELECT FROM \"apm*\" where = '" {var appName} "' and processor.event = 'transaction' and > 2 "}

  | var_set name="count" value={rowCount }

  | var_set name="color" value={var "count" | if condition={eq 0} then="#AAAAAA" else="#f2bc33"}
1 Like

hey I found one of my issues. my id begins with digit, so I need to define
var_set name="id" value="'123abc'"

@Felix_Roessel thank you very much, you helped me with solution to my variabe issue. Although my original question is about time filtering so, I did not marke your last example as a solution.
My next attempts are:

  • changing global variable from drop down (is this even possible?)
  • make the original q. time filter work :smiley:

No you cant change a global variable by dropdown. The dropdown is changing the filter context itself.
I've created a PR to be able to set a default value in a dropdown. That helps to change the filters e.g. by using the urlparam functions

1 Like

ok good to know