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:
Allow custom fields ("custom columns") to work with text and datetime fields · Issue #11330 · metabase/metabase · GitHub - 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:
Summarizing by Distinct datetime column always sets granularity to Month · Issue #13098 · metabase/metabase · GitHub
It would probably be easier to do in SQL. But you could just get the count like this and join that saved question perhaps: