Test for duplicates values

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!

4005d72b-4e35-413a-9427-fc510ecc1475.png
Solved Solved
0 3 987
1 ACCEPTED SOLUTION

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

View solution in original post

3 REPLIES 3

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!

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

Top Labels in this Space
Top Solution Authors