Adding Metabase to Metabase to query Metabase in Metabase

2020-09-04

There are a lot of obscure, one-off queries I've saved in Metabase to answer different questions about our business. For example, I pretty regularly need to do some percentile-based rankings to estimate the impact of a product feature, and for the life of me can never remember how to construct a percentile query—but I can remember some keywords from past queries.

It turns out you can add the Metabase database to your Metabase settings. Just put in the host and credentials to your database, call it Metabase, and save. Then you can write a query like this (this uses SQL parameters so you can just plug in a new keyword each time):

1select 2 questions.name, 3 collection.name, 4 'https://metabase.example.com/question/' || questions.id as url, 5 questions.description 6from report_card as questions 7left join collection on collection.id = questions.collection_id 8left join core_user as users on users.id = questions.creator_id 9where questions.dataset_query ilike concat('%', {{search}}, '%')

Which will allow you to query all your saved Metabase questions by keyword:

Hat tip to bkrausz for the idea.

← all posts

michael schade

I like learning new things. Previously: Kenchi founder, eng & ops teams at Stripe from 2012-2019. Say hi! 🏳️‍🌈