Custom Question Editor - Distinct rows instead of duplicated rows when user explore

Ehy Guys,

I created a custom question using the custom editor, having multiple JOIN.

I have been able to select the columns relevant to me for each JOIN.

Now I want to allow users to drill into the data.

My problem is that the generated table has duplicated rows, I would love to have DISTINCT rows.

Is there a way for me to explicitly say that when a user explore the data only DISTINCT rows are displayed?

Many thanks.

Hi @erre
You would have to make the joins, so they don't produce duplicate rows. Or summarize the results. Or use SQL.
It sounds like you're using the wrong columns to join with - or the wrong join type.

Here the JOIN I am making, they are correct, but by default they produce duplicated rows, which I could simply remove adding a DISTINCT.

Is there a way to change JOIN type or to add a DISTINCT keyword?

Best

@erre You would have to do that in SQL.

Got it, many thanks!

It might be an interesting feature to add, a simple flag "remove duplicates if any"

Best

1 Like

@erre You can remove duplicates by grouping by columns you want to return. I doubt that Metabase will get such a feature, since it is not normal to have duplicate rows if you're doing normal joins on logical columns, and it would be too easy for people to get unexpected results.

I might be wrong (usually am), but isn't SELECT more foundational to SQL than JOIN? i.e, Since it is 'normal' to have duplicate rows in any given list, and it is normal to return duplicative rows in any given query, wouldn't it make sense to provide users an easier way to group data than to build an entirely new question/model?

For some reason, even with a single column selected in a Metabase join, you must convert it to SQL, SELECT distinct, and reformat your columns to avoid returning additional unwanted columns.

Also, shameless plug for another improvement: if the db source listing vector search field could sort using the actual search string, it would save me countless minutes scrubbing a list of 200 tables. Searching reorders an unwieldy list, but doesn't seem to sort or filter.