vendredi 26 août 2016

Incrementing Values with If Statement

Here is what I am trying to do:

I have data. This data is unstructured and I am trying to make it look neat so that I can do something with it.

There is a column called "Address". If the address column takes the value "ADDRESS" then I want to do a count where the value takes 1. If it is anything other than "ADDRESS" I want the count to increment.

What it currently does: My counter takes the value of 1 if the value "ADDRESS" appears, and it increments if the value is not "ADDRESS" but the value does not reset itself. It keeps going as if nothing ever happened.

My code:

var count_y = -1;

for(a = 0; a<= New_Row_Num; a++){

    if(Address == 'ADDRESS'){
        count_y = 1;
        //count_y == 0;

    }else{

        count_y += 1;

    }
}

What I have tried that did not work other than the code posted above: I tried creating an array and assigning it a value of 1. If the "address" column has the value 'ADDRESS' the array goes back to being a value of 1, otherwise the array would increment in value. This had the same effect as above, just with different numbers.

Please help me understand what I am doing wrong, thank you.

Aucun commentaire:

Enregistrer un commentaire