I want to create a measure which will calculate the statistical mode for a given value.
The SQL equivalent would be:
SELECT TOP 1 Column_NameFROM Table_nameGROUP BY [Column_Name]ORDER BY COUNT(*) DESC
I can see how to get this value while looking at data in an Explore, but given a model with dimension DIM and Measure M, I want to be able to write a second measure that is something like this:
measure: modal_M {
type: number
sql: STUFF GOES HERE ;;
}
When viewed in an explore, modal_M would provide the modal value of M, which could be sliced by DIM or any other dimension.
Example output:
Country | Modal_FirstName_Length
USA | 8
Canada | 12
Mexico | 11