Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert blank values to zero when using the Query function

Is there a way to convert data going into a query() function so that blank/null values are converted to zero?

I have a dataset with three columns:

Group    AC       Plan
Comms    350      [blank]
IT       50,000   85,000
Rent     15,000   15,000
Training [blank]  8,500

I want to query the set to find the difference between AC and Plan,
e.g. =query('data', "select A, B-C",1). However, since the query omits blank cells when calculating B-C, the result is like this:

Group    Diff
Comms    [blank]
IT       -35,000
Rent     0
Training [blank]

When I wanted this:

Group    Diff
Comms    350
IT       -35,000
Rent     0
Training -8,500

Before you go wild: I am not able to change the source data (the incoming data is actually another query() using the pivot functionality). And the reason I need this to work is I use a limit clause to confine the results to only the top 25 and bottom 25 differences.

like image 897
a-burge Avatar asked May 24 '26 23:05

a-burge


1 Answers

=ARRAYFORMULA(IF(QUERY(T3:V7)="", 0, QUERY(T3:V7)))

0

like image 164
player0 Avatar answered May 27 '26 13:05

player0