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 1,018
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
Top Labels in this Space
Top Solution Authors