TLDR: How can I apply MIN/MAX in measures to multiple columns?
We have a table `Person` and 2 joined tables `event1` and `event2`. Each of the event tables have date columns, lets call them ‘updated’ and ‘contacted’.
According to this article I can create a measure with min/max value for a single column as follows
measure: last_updated_date { type: date sql: MAX(${updated_raw}) ;; convert_tz: no}
But how do I get the min/max value for each `person.id` from two columns (`event1.updated` and `event2.contacted`)?
Solved! Go to Solution.
Thanks!
That was my initial approach as well but then I got stuck at how to get the `min` from both columns, i.e. the `min` from `min_updated` and `min_contacted`.
Ah, I didn’t understand that as the objective.
If your database has the least/greatest function, that could do it.
dimension: person_min_date {
type: date
sql: least({$contacted_date}, {$updated_date})
}