Test for duplicates values

  • 13 December 2021
  • 3 replies

Hi all!

I have just started using LookML and I wanted to create a test that will allow me to know if there are duplicate values in my final table in Looker. For this test, I am using primary_key column and this is how I have wrote the test. The logic I followed is that if there are the same number of distinct primary key values to the count of primary key values, means that there are no duplicates.

test: no_duplicate_values {
  explore_source: orders {
    column: primary_key {
      field: orders.primary_key
  assert: no_duplicate_values {
    expression: count_distinct ( ${orders.primary_key} ) = count( ${orders.primary_key} );;


Could someone tell me if this is written properly or if there is another way to do it? The error I get when I run the test says  what you can see in the picture attached. Thanks for the help!



Best answer by Dawid 13 December 2021, 08:56

View original

This topic has been closed for comments

3 replies

Userlevel 7
Badge +1

I used exact same test in one of my explores and it runs fine. Double check that your source explore is referenced correctly

I think the problem is coming from the explore_source parameter. I look through internet how this needs to be referenced, but couldn’t find an answer. Would you mind to tell me how this needs to be done? thanks!


Userlevel 7
Badge +1

You just use the name of the explore, I can’t see what’s the explore’s name in your screenshot, so we can’t verify it