Meaning of the Error
In Looker, you might come across an error of this form:
Non-Unique value/primary key (or sql_distinct_key
), value overflow or collision when computing sum
This error occurs when Symmetric Aggregates (formerly Joined Sums and Averages) is used to bring measures through a join. It indicates that a field defined as primary_key: true
in one of the views involved in the join is not completely unique for the values being calculated, and therefore cannot safely be used to make distinct aggregates. It is usually caused by creating a calculation based on a dimension from another view further down in the join hierarchy, or when your primary key is not unique.
Resolving This Error
Make sure any field you have defined as primary_key: true
is unique in its table. One way to test this is to create an Explore for the view you want to test, then make a Look with that primary key and a count of the table. Sort on the count, and look for instances where count is greater than 1; this indicates a non-unique field.