Google Data Studio (BigQuery) - Create filter to select by latest hour

685 Views Asked by At

I have a columns DATE, TIME (only hour number) and GROSSVALUE

DATE          TIME     GROSSVALUE
2018-09-12    13       734564
2018-09-12    12       234324

How to use Scorecard to display GROSSVALUE for the current and previous hour?

IF currently is 2018-09-12 (and any time between 13:00 to 13:59)

EXAMPLE:

--------------

CURRENT

________________
|              |
|   734564     |
|______________|

PREVIOUS

________________
|              |
|   234324     |
|______________|
1

There are 1 best solutions below

0
On

Does the BigQuery LAG() function get what you're after? Something like:

SELECT GROSSVALUE
   , LAG()GROSSVALUE AS GROSSVALUE_last_hour
FROM DATASOURCE
ORDER BY DATE
   , TIME