ifnull with table calculations

I am new to Looker and I am experiencing problems creating simple calculations. For example, I have created 2 table calculations using the diff_days function to get the number of days between a start and end date as shown below. The first statement uses a data element titled "waiting_list_start_date" and now(), and the second statement uses 2 data elements titled "waiting_list_start_date" and "waiting_list_end_date"

days_waited_with_Now = diff_days(${service_attributes_generic.e5189b77_f5eb_45c7_ad7f_d1e7514fc504_waiting_list_start_date},now())

days_waited_with_End = diff_days(${service_attributes_generic.e5189b77_f5eb_45c7_ad7f_d1e7514fc504_waiting_list_start_date},${service_attributes_generic.e5189b77_f5eb_45c7_ad7f_d1e7514fc504_waiting_list_end_date})

The "waiting_list_end_date" field in the second statement is not always entered.

I want to create a new table calculation or dimension that will compare the results from the 2 table calculations above so if the days_waited_with_End is null then use the days_waited_with_Now but I can't seem to figure out how to do so. Here's the new statement I am using but I am getting an error on the ifnull statement:

ifnull(${days_waiting_with_End},${days_waiting_with_Now})

The error is Unknown function "ifnull".

How can I achieve the required result to use one of the table calculations over the other if the first one is null?

Solved Solved
0 1 47
1 ACCEPTED SOLUTION

I figured this out. Instead of using table calculated fields I created custom dimensions and then used the following statement:

if(${days_waiting_with_End} > 0,${days_waiting_with_End},${days_waiting_with_Now})

View solution in original post

1 REPLY 1

I figured this out. Instead of using table calculated fields I created custom dimensions and then used the following statement:

if(${days_waiting_with_End} > 0,${days_waiting_with_End},${days_waiting_with_Now})

Top Labels in this Space
Top Solution Authors