Number of arguments does not match for aggregate function COUNT

I am creating a LookML dashboard which requires some measures that are calculating a COUNT_DISTINCT on two fields from a table. From my understanding, COUNT_DISTINCT should be able to take in 2 arguments but I keep getting the error that is attached. I have reached out to Looker Support numerous times but they do not seem to have an answer. They have created test measures using 2 fields as arguments in COUNT_DISTINCT but did not have any issues. Has anyone else run into this problem?
Screenshot 2023-06-30 at 4.22.54 PM.pngScreenshot 2023-06-30 at 4.20.24 PM.pngScreenshot 2023-06-30 at 4.23.44 PM.png

0 3 2,419
3 REPLIES 3

You didn't mention which Database you are using, but Standard SQL does not allow two arguments in count distinct

The below would end up in error, So it is not a problem with Looker/LookML.

select count(distinct col1, col2) from table.

If you want to count distinct on two columns you can use double pipe or Concat function depends on your database.

  measure: test_count_distinct {
    type: count_distinct
    sql: ${TABLE}.column1 || ${TABLE}.column2 ;;
  }

 

 

Apologies. I am using BQ Standard SQL. I have tried many iterations of your proposed solution (using CONCAT, pipe, and event taking out DISTINCT) but still am seeming to have the same error.Screenshot 2023-07-03 at 2.44.56 PM.pngScreenshot 2023-07-03 at 2.48.07 PM.png

 @tmordan If it is a Standard BigQuery SQL, double pipe will work, I checked it on my end. I think there might be a minor details that trips you. Would be able to post the entire SQL ( You can remove the table name) here ?

prabhakaran_mai_0-1688418149857.png

 

Top Labels in this Space
Top Solution Authors