How to give alias to field filter?


I have a column which is very technical and I want to use another term which is more user friendly. In this case, column is vehicle type, on database we use 1 for car and 2 for motorcycle.

On query I can use alias by using decode or if case. But on the field drop down filter how to change these value 1 and 2 respectively to car and motorcycle?


Let’s keep the same question in one topic: Use of table alias

Actually this is different issue. Here I’m asking how to put alias to drop down filter variables? Not table alias.

@erich.sw Okay, then I don’t understand. Please post the query.

Ok the query basically like this

SELECT month(o_date) as month,
COUNT(if(v_type=‘1’,order_number,NULL)) AS ‘car’,
COUNT(if(v_type=‘2’,order_number,NULL)) AS ‘bike’
from my_table
where {{v_type}}

So in this case the drop down field filter in dashboard is either 1 or 2. How do I change this filter into car and bike respectively?


@erich.sw Sounds like you’re looking for “Custom mapping” of display values:

yes exactly this kind of feature. Thanks for pointing…I will learn it, because my table and this column is not foreign key to another table. Yet I cannot find a way to make it a custom mapping. And in fact some of other columns are text not numerical.

@erich.sw Currently only numerical columns are supported. There’s an issue open of string support: - upvote by clicking :+1: on the first post
A workaround is to create a database view, so you do all the conversion there and Metabase just sees a regular table.

Thanks @flamber