Skip to main content

MetricFlow Tutorial

This is a short tutorial once you have set up MetricFlow. This guide is for new users and assumes that you have MetricFlow set up and deployed. Check out our deployment docs if you have not completed this step.

Congratulations! You’re fully set up with MetricFlow. Here are some commands to run against the sample models you’ve created via mf tutorial.

Trying to figure out what metrics there are?

mf list-metrics

You’ve found the metrics! Do you want to learn more about a certain metric’s dimensions?

mf list-dimensions --metric-names new_customers

or view the dimensions available across a list of metrics:

mf list-dimensions --metric-names 'new_customers, transactions'

Now that you understand what metrics and dimensions you have in the model, run some queries!

mf query --metrics transactions --dimensions metric_time --order metric_time

Now try adding --explain to see the SQL:

mf query --metrics transactions --dimensions metric_time --order metric_time --explain

Would you want to see this metric grouped by another dimension?

mf query --metrics transactions --dimensions 'metric_time, quick_buy_transaction' --order metric_time

How about grouped by another dimension from a multi-hop join?

mf query --metrics transactions --dimensions 'metric_time, customer__country__region' --order metric_time

Are you curious about how these metrics look on a weekly time granularity?

mf query --metrics transactions --dimensions metric_time__week --order metric_time__week

Did you want to see the most recent values first? That’s no problem for MetricFlow!

mf query --metrics transactions --dimensions metric_time__week --order -metric_time__week

Try it now with a more complicated cumulative and filter metric!

mf query --metrics transaction_usd_na_l7d --dimensions metric_time --order metric_time

Add in --explain here to see how MetricFlow handles the joins and date spine!

mf query --metrics transaction_usd_na_l7d --dimensions metric_time --order metric_time --explain

Let's get funky and try querying multiple metrics at once with a where.

mf query --metrics transactions,transaction_usd_na,transaction_usd_na_l7d --dimensions metric_time,is_large --order metric_time --where "metric_time between '2022-03-20' and '2022-04-01'"

Please let us know if you have any questions or additional functions we should add to this tutorial! Slack Community #docs-feedback.