# Using nested conditional statements in QGIS Raster Calculator

I'm currently working on a project in QGIS and have encountered an issue with formulating a nested conditional statement in the Raster Calculator.

How do I resolve this?

My goal is to perform a raster calculation that prioritizes data from three different raster layers ("National_rp@1", "District@1", and "Water@1"), and uses slope data from a fourth raster ("Slope_rw_rp@1") only if all three of the other raster layers have null values for a particular cell.

I have tried:

``````if(isnull("National_rp@1") AND isnull("District@1") AND isnull("Water@1"),
6 * 2.71828 ^ (-3.5 * abs("Slope_rw_rp@1" + 0.05)),
if("National_rp@1" = 1, 90,
if("National_rp@1" = 2, 50,
if("District@1" = 1, 70,
if("District@1" = 2, 30,
if("Water@1" = 1, 9999999, 0)
)
)
)
)
)
``````

But I get a generic Raster calculation error.

• `isnull("District@1")` does not seem to be a valid expression, why do you think it is? Jan 12 at 15:12

Short answer: convert `NoData` values to a numerical value, then use an equal (=) statement to get a binary (0/1) output that you can use to multiply the result instead of nester if-statements.
In detail: Working with `NoData` cells is tricky and the syntax `isnull("District@1")` is not a valid expression. QGIS raster calculator does not seem to have an operator to treat NoData cells (see also here) - I don't know from where you have the `isnull()` operator.
You can use Fill NoData cells to convert NoData pixels to a fixed value (e.g. 999999) and then use this one in the raster calculator to see if the raster value is equal to this, in which case you get 1: `("National_rp@1" = 9000)` - when the output is 1, this means the raster value is `NULL`. Do this for all three rasters and multiply the results: if all three values are 1, you get 1. If one of the values is `0` (thus: one of the three raster is not `NULL`), the output is 0
``````    if (