Question

Time Range selector - second precision

  • 9 May 2021
  • 1 reply
  • 17 views

Hello,

I am using a Time Range Selector in a dashboard. The range precision is the minute level.

I need to specify second level precision in the time range. How can I do that?

 

 


1 reply

Userlevel 3

Definitely won’t be able to get that functionality with just a singular `is in range` filter - range time filtering only gives (currently) precision to a minute range. Probably the easiest way to handle this though would be to have a number dimension (that has the seconds) and add a second filter that specifies the range of seconds. 

 

Eg: say this is the original dimension group you’re filtering on

 

```

dimension_group: my_time_field {

type: time
sql: ${TABLE}.time_field ;; 
}
```

Have another dimension that does:

 

```

dimension: seconds {
type: number
sql: EXTRACT( seconds FROM ${TABLE}.time_field ;; 
}
```

Then filter on that. The `EXTRACT()` function there would need to be whatever your dialect’s equivalent of that function is. You can also use a little known LookML param if you don’t want to look up your dialect’s time functions, `expression`:

 

```

dimension: seconds_hacky {

type: number

expression: extract_seconds(${TABLE}.time_field ;;

}

```

`expression` lets you use many table calc functions in LookML, in lieu of writing SQL in a `sql` parameter - Looker then translates that into SQL at runtime. Note, there are limitations to `expression` and there is no documentation, so use at your own risk :)

Reply