How to filter by month and year by a generated column?

I have a transactions table with amount and date columns. If the amount > 0, it is an expense, otherwise, its an income.

I want to display a table with income vs expense as a ratio that has a "month and year" variable but I'm wondering what's the best way to do this.

My current attempt:

SELECT 
date_trunc('month', date) AS txn_month, 
sum(case when amount > 0 then amount else 0 end) as monthly_expense,
abs(sum(case when amount < 0 then amount else 0 end)) as monthly_income
FROM transactions
where transactions
GROUP BY txn_month;

This gives the right result
image

However, I can't use a month+year filter on this in a dashboard. It says there aren't any valid fields.
image

Solved. Had to use a field filter

Just adding documentation link for others: https://www.metabase.com/docs/latest/questions/native-editor/sql-parameters