Getting the distinct number of months from a table's column with dates in a personalized expression

Hi,

I am trying to calculate a ratio in a personalized expression where I need have access to the distinct number of months in a table. I have a column with date objects and would like to get the distinct number of months from that column.

“Distinct” in the personalized expression editor does not seem to be able to take date columns as a parameter. Any idea on how I should proceed ?

Thank you in advance,

Anton

Hi @anton1
Custom Expressions does not handle dates really:
https://github.com/metabase/metabase/issues/11330 - upvote by clicking :+1: on the first post
And you would need to be able to define the binning/granularity too, which is currently not possible in Custom Expressions either - nor in the normal metrics:
https://github.com/metabase/metabase/issues/13098
It would probably be easier to do in SQL. But you could just get the count like this and join that saved question perhaps: