@@ -124,13 +124,14 @@ df = dataset.to_pandas()
124
124
As shown above, the ` Query ` object allows you to easily compile MBQL from Python objects. Here is a
125
125
more complete example:
126
126
``` python
127
- from metabase import Query, Sum, Average, Greater, GroupBy, BinOption, TemporalOption
127
+ from metabase import Query, Sum, Average, Metric, Greater, GroupBy, BinOption, TemporalOption
128
128
129
129
query = Query(
130
130
table_id = 5 ,
131
131
aggregations = [
132
132
Sum(id = 5 ), # Provide the ID for the Metabase field
133
- Average(id = 5 , name = " Average of Price" ) # Optionally, you can provide a name
133
+ Average(id = 5 , name = " Average of Price" ), # Optionally, you can provide a name
134
+ Metric.get(5 ) # You can also provide your Metabase Metrics
134
135
],
135
136
filters = [
136
137
Greater(id = 1 , value = 5.5 ) # Filter for values of FieldID 1 greater than 5.5
@@ -147,7 +148,8 @@ print(query.compile())
147
148
' source-table' : 5 ,
148
149
' aggregation' : [
149
150
[' sum' , [' field' , 5 , None ]],
150
- [' aggregation-options' , [' avg' , [' field' , 5 , None ]], {' name' : ' Average of Price' , ' display-name' : ' Average of Price' }]
151
+ [' aggregation-options' , [' avg' , [' field' , 5 , None ]], {' name' : ' Average of Price' , ' display-name' : ' Average of Price' }],
152
+ [" metric" , 5 ]
151
153
],
152
154
' breakout' : [
153
155
[' field' , 4 , None ],
0 commit comments