Question

Boolean filter expression with null values

  • 19 June 2019
  • 3 replies
  • 1709 views

I created measure with a filter and the field I use in that expression is a boolean type with true/false values, however the field contains null values as well.

here’s how I define the measure:


  measure: aged_25_34 {
type: count
filters: {
field: age
value: "TRUE"
}
}

The query returns:


No matching signature for function UPPER for argument types: BOOL. Supported signatures: UPPER(STRING); UPPER(BYTES)


Is there any hack to get around this?


3 replies

Userlevel 7
Badge +1

Age is a boolean here? By boolean, do you mean it’s a lookml dimension of type: yesno? If so, you actually say


 measure: aged_25_34 {
type: count
filters: {
field: age
value: "Yes"
}
}

instead of TRUE. That might help!

Hi @izzy! it’s a boolean field in the database(bigquery) but I’m using it as a LookML dimension which is of type string and the values are shown as:

image


Looker translates my filter into this expression that expects the dimension to be of type boolean.


SELECT 
COUNT(CASE WHEN (UPPER(age) = UPPER('Yes')) THEN 1 ELSE NULL END) AS customer_profile_age
FROM customer AS customer_profile
LIMIT 500

still returning the same error

Userlevel 7
Badge +1

Ooookay my wager here is that somehow, case_sensitive: is being applied to the age field in the lookml. That’s the only thing in Looker that’d automatically insert those UPPER clauses.


Can you verify that there’s a case_sensitive: no parameter being applied somewhere in the reference chain there, and try removing it? If you’d like to maintain the boolean status of that field, you might look into using a yesno type:




🙂

Reply