How can I divide the result of 2 cards in a dashboard


#1

I have the SQL program of 2 different cards giving me a result each. I want to create a third card that can bring all the information of the result of dividing the 1st result by the 2nd, is it possible?

1st card)

SELECT
COUNT (distinct smartlockimei) AS completed
FROM trips_view t inner join users_view u on t.userid = u.id
WHERE
(enddate_txt >= to_iso(DATE_TRUNC(‘day’,now()) AT TIME ZONE ‘utc’ AT TIME ZONE ‘AMERICA/Sumpa’ ))
AND enddate_txt < to_iso(DATE_TRUNC(‘day’,now()+ INTERVAL ‘1 day’) AT TIME ZONE ‘utc’ AT TIME ZONE ‘AMERICA/Sumpa’ )
AND t.viculotype = {{viculo}}
AND t.status = ‘ENDED’
AND t.receipt_totalamount > 0
AND t.receipt_duration > 1 * 60
AND t.receipt_duration < 4 * 60 * 60
AND right(u.email, 10) != ‘@gmail.com
AND right(u.email, 12) != ‘@hotmail.com
AND city_id = {{city_id}}

2nd card)

select
count (distinct bakas.id) as rua
from tusks
JOIN bakas ON bakas.id = tusks.baka_id
where Tusks.tusk_type_id = ‘10’
[[AND bakas.city_id = {{city_id}}::text]]
AND date(tusks.created_at at time zone ‘Utc’ at time zone ‘America/Sumpa’) = date(now())
AND bakas.viculo_type = ‘Ebaka’
AND result @> ‘{“destination”: “strut”}’

How would be this 3rd card?


#2

Hi @henrique836
Metabase currently doesn’t have a feature like that. You would have to either create a single query, where you divide the two sub-queries, or create a View and do the same.