Knowledge Drop

How can I find the the first non-null row for a column?


Userlevel 5

Last tested: Nov 2, 2018
 

There are several methods mostly using the first_value() window function, so results may vary based on your SQL dialect.

If your result set is less than 5000 rows, this Table Calculation pattern will work:

To find the first non-null record in column orders.count:

max(

if(

row()=min(match(${orders.count}, ${orders.count})),

${orders.count}, 0))

 

More details on this article.

 

This content is subject to limited support.                

 

 


0 replies

Be the first to reply!

Reply