If / Else Statements

Hi all - I’m trying to combine several “type of” columns into one and I’m getting “Othernullnullnullnullnullnullnullnullnull”. This was done with a basic computed column:

row[“Type of Cutting Tool”]+row[“Type of Equipment”]+row[“Type of Firearm”]+row[“Type of Fishing Equipment”]+row[“Type of Forest Product”]+row[“Type of Mining Equipment”]+row[“Type of Traditional Weapon”]+row[“Type of Vehicle”]+row[“Type of Trap”]+row[“Type of Ammunition”]

However, what I’d like it to return in the above example is “Other” and for all the null values to be blank.

I’m pretty sure I can do this with if/else statements, but I can’t seem to get it down. For example, in the below example, there’s two observations returned - an ntfp and a shotgun. They’re both displaying in the incorrect table above (red circle). In the second table, it’s displaying better (without “null”), but it’s only showing “Honey”.

The code for the second table is:

if(row[“Type of Firearm”] == null ){
row[“Type of Firearm”];
if(row[“Type of Forest Product”] == null ){
row[“Type of Forest Product”];

What I ultimately need is a cascading set of if/else statements, that goes through each of the 10 attributes in the first bit of code and returns whichever one there is a value for.

Feels like I’m missing something obvious here - so any ideas would be most appreciated!

You just need to drag and drop the data into one column, and change the properties to inline


Lili Sadikin

@LiliSadikin Not sure I understand your recommendation… can you clarify?

Hi Drew

You don’t need computed column.
You just need add new column to the table, then drag the data into that.
Change the display of your data from block into inline.

You can give a space within data by using label with a space.

Here the result

On this example, I copy the data to new column, but you can drag and drop.

Lili Sadikin

@LiliSadikin Thanks for this. I wasn’t aware you could do this - so it’s really exciting to learn!

Unfortunately, it only gets me part of the way to where I want to be. See the attached screenshot. The problem with your solution, as I see it, is that the table still creates a space for each data item, even if the value is null. In my use case, there will only ever be one value in the cell (e.g., Shotgun or Honey) and I want ONLY the one value to be visible. This should result in only one row. Right now, the table has space for each of the 10 values I’ve dragged and dropped into that cell.

For that reason, I think I ultimately need a if/else statement (or some sort of condition). Any further thoughts about how that might work? It’s essentially working now - the issue is just that the formatting is ugly at the moment.

Thanks all!

Hi Drew

You can use this way to hide the empty space
Visibility → Hide Element → Script with NULL

Before hide element

After hide element

Best Regards

Lili Sadikin

@LiliSadikin Awesome! That did it (see my “item type” column appearing as desired in the table attached).

Had never used the visibility feature - really cool. Thanks again!