Display inline code and code blocks
model
decorator from vinyl and create function.
store_nbr | city | num_transactions |
---|---|---|
01003 | San Francisco, CA | 11026 |
03001 | Brooklyn, NY | 10981 |
06002 | Austin, TX | 8193 |
MetricStore
object to our function and pass in the timestamp column to the metric
method.
shop_sales
can now be used throughout our Vinyl project. The Metrics layer allows for dynamic queries across dimensions and time buckets. Metrics also provide useful features like fill options and trailing windows.
If we want to get the sales across each shop location over the past trailing 3 months, we can query it like:
ts | store_nbr | city | sales |
---|---|---|---|
2023-12-01 | 01003 | San Francisco, CA | 752 |
2023-12-01 | 03001 | Brooklyn, NY | 1130 |
2023-12-01 | 06002 | Austin, TX | 534 |
2023-01-01 | 01003 | San Francisco, CA | 304 |
2023-01-01 | 03001 | Brooklyn, NY | 540 |
2023-01-01 | 06002 | Austin, TX | 121 |
2023-02-01 | 01003 | San Francisco, CA | 910 |
2023-02-01 | 03001 | Brooklyn, NY | 1520 |
2023-02-01 | 06002 | Austin, TX | 862 |
ts | store_nbr | city | sales |
---|---|---|---|
2023-02-01 | 01003 | San Francisco, CA | 619 |
2023-02-01 | 03001 | Brooklyn, NY | 811 |
2023-02-01 | 06002 | Austin, TX | 407 |
2023-02-15 | 01003 | San Francisco, CA | 291 |
2023-02-15 | 03001 | Brooklyn, NY | 709 |
2023-02-15 | 06002 | Austin, TX | 455 |