<html style="direction: ltr;">
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
  </head>
  <body style="direction: ltr;" bidimailui-charset-is-forced="true"
    smarttemplateinserted="true" text="#000000" bgcolor="#FFFFFF">
    <div id="smartTemplate4-template">
      <div id="my_message" style="color:blue; ">
        Here's a way to accomplish what you want in a Spatialite table<br>
        <br>
        I saved your sample 4 rows as a CSV:<br>
        <br>
        row_id,strike,dip,rake,magnitude,quadrant,depth<br>
        0,,,,,Tensional and Compressional,<br>
        1,233,38,-96,6.77,Compressional,623<br>
        2,,,,,Tensional and Compressional,<br>
        3,68,36,83,5.7,Compressional,39<br>
        <br>
        Then I imported the CSV to Spatialite_gui and ran this query:<br>
        <br>
        UPDATE earthquakes SET depth=(SELECT e.depth FROM earthquakes AS
        e WHERE e.rowid=(earthquakes.rowid+1)) <br>
        WHERE depth IS NULL;<br>
        <br>
        Then I got:<br>
        0    0    0    NULL    NULL    NULL    NULL    Tensional and
        Compressional    623<br>
        1    1    1    233    38    -96    6.770000    Compressional   
        623<br>
        2    2    2    NULL    NULL    NULL    NULL    Tensional and
        Compressional    39<br>
        3    3    3    68    36    83    5.700000    Compressional    39<br>
        <br>
        HTH,<br>
        Micha<br>
        <br>
      </div>
    </div>
    <div id="smartTemplate4-quoteHeader">------ Original Message ------
      Subject: Re: [Qgis-user] Edit attribute table rows
      Date: Fri, 8 Apr 2016 17:17:09 +0100
      To: Andreas Neumann, Qgis-user
      From: Lester Anderson</div>
    <br>
    <br>
    <div class="moz-cite-prefix">On 04/08/2016 07:17 PM, Lester Anderson
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAE3taFAoE9WG8vcCsSYaTpTe1RUhh-aSjmRyc5fc4bO_UaMs5A@mail.gmail.com"
      type="cite">
      <pre wrap="">Hi Andreas,

Still having issues. I can see the logic of the CASE WHEN END, but I
am wondering if the problem is because "Depth" has both a NULL value
and a real value. I have tried all sorts of variants and cannot get
the NULL depth changed.

Attributes: strike dip rake magnitude quadrant depth
0 null null null null null "Tensional and compressional" null
1 233 38 -96 6.77 Compressional 623

So scanning for Depth=NULL is fine; this is actually all of the event
solutions, where the row with the values defines the nodal planes. I
have around 2928 events in the shapefile!

Can this be solved by scanning for the quadrant attribute, but then
how does one specify the value for "Depth". I think if one applies
"Depth" NOT NULL it returns 1

I could not find a guide in the documentation for the field calculator
that was similar.

Cheers
Lester

On 8 April 2016 at 15:00, Neumann, Andreas <a class="moz-txt-link-rfc2396E" href="mailto:a.neumann@carto.net"><a.neumann@carto.net></a> wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">Hi Lester,

The field calculator is meant to change "a lot" of values. It will update
all selected records with the new value or calculation (expression).

With CASE WHEN END you can introduce switches for different rules.

So - please don't export to Excel. You can do it all with the field
calculator.

Andreas

On 2016-04-08 15:28, Lester Anderson wrote:

Hi Andreas,

I am trying change a lot of values, if it was a few that is no problem.

The other option is to export the attribute table as a database and
edit in Excel etc and then join the table in QGIS

Cheers
Lester

On 8 April 2016 at 14:23, Neumann, Andreas <a class="moz-txt-link-rfc2396E" href="mailto:a.neumann@carto.net"><a.neumann@carto.net></a> wrote:

Hi Lester,

I thought you want to set the value to 623 where the value was NULL before?
- so just write 623 in the left field after you selected the values.

Alternatively, you can do without the previous selection and use the
following expression.

CASE WHEN depth IS NULL THEN 623 ELSE depth END

Hope this helps,

Andreas



On 2016-04-08 15:13, Lester Anderson wrote:

Hello Andreas,

Selecting the rows where depth = NULL is fine. The field calculator
does not update the depth with the depth where known values are
present.

Only update selected features is checked, update existing field
checked, with output field set to depth:
Expression: tried just "depth" and also "depth"="depth".

Have I missed something here?

Thanks

On 8 April 2016 at 12:30, Neumann, Andreas <a class="moz-txt-link-rfc2396E" href="mailto:a.neumann@carto.net"><a.neumann@carto.net></a> wrote:

Sure.

It is a two-step thing:

1. Select all records where Depth IS NULL. Use the "Select Features using an
expression" button (the Epsilon sign) for that and "depth IS NULL" as an
expression

2. Use the field calculator and only update the selected records (the top
checkbox in the field calculator).

You can find details about the field calculator in the QGIS manual.

Hope this helps,

Andreas

On 2016-04-08 13:18, Lester Anderson wrote:

Hello,

I have an attribute table of earthquake data (focal mechanism beach
balls) and need to edit the depth attribute. Each ball is defined by
two rows in the table, eg first ball

Row_ID Strike Dip Rake Magnitude Quadrant Depth
----------------------------------------------------------
0 NULL NULL NULL NULL Tensional and Compressional NULL
1 233 38 -96 6.77 Compressional 623
2 NULL NULL NULL NULL Tensional and Compressional NULL
3 68 36 83 5.7 Compressional 39
etc

where rows 0,1 and 2,3 represent separate beach balls, so basically it
is a row calculation

What I need to do is replace the Depth NULL value with the depth 623
etc for each entry. Is there an easy way of doing this?

Thanks

Lester
_______________________________________________
Qgis-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a>
List info: <a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-user">http://lists.osgeo.org/mailman/listinfo/qgis-user</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-user">http://lists.osgeo.org/mailman/listinfo/qgis-user</a>










</pre>
      </blockquote>
      <pre wrap="">_______________________________________________
Qgis-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a>
List info: <a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-user">http://lists.osgeo.org/mailman/listinfo/qgis-user</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-user">http://lists.osgeo.org/mailman/listinfo/qgis-user</a>
This mail was received via Mail-SeCure System.
</pre>
    </blockquote>
    <div class="moz-signature">
      <div dir="LTR">
        Micha Silver<br>
        Arava Drainage Authority<br>
        +972-523-665918
      </div>
    </div>
  </body>
</html>