<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p><font face="Arial">You could try a "CASE" expression:</font></p>
    <p><br>
      <font face="Arial"><span style=" font-family:'Lato,Ubuntu,Lucida
          Grande,Segoe UI,Arial,sans-serif'; font-size:large;
          font-weight:600; color:#93b023; background-color:#f6f6f6;">expression
          CASE</span></font></p>
    <span style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe
      UI,Arial,sans-serif'; color:#000000;"></span><span style="
      font-family:'Lato,Ubuntu,Lucida Grande,Segoe UI,Arial,sans-serif';
      color:#000000;"></span>
    <pre style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; color:#000000;">CASE</span><span style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe UI,Arial,sans-serif'; color:#000000;">
</span><span style=" font-family:'Courier New'; color:#000000;">WHEN </span><span style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe UI,Arial,sans-serif'; font-style:italic; color:#000000;">condition</span><span style=" font-family:'Courier New'; color:#000000;"> THEN </span><span style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe UI,Arial,sans-serif'; font-style:italic; color:#000000;">result</span><span style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe UI,Arial,sans-serif'; color:#000000;">
</span><span style=" font-family:'Courier New'; color:#000000;">[ …n ]</span><span style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe UI,Arial,sans-serif'; color:#000000;">
</span><span style=" font-family:'Courier New'; color:#000000;">[ ELSE </span><span style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe UI,Arial,sans-serif'; font-style:italic; color:#000000;">result</span><span style=" font-family:'Courier New'; color:#000000;"> ]</span><span style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe UI,Arial,sans-serif'; color:#000000;">
</span><span style=" font-family:'Courier New'; color:#000000;">END</span><span style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe UI,Arial,sans-serif'; color:#000000;">
</span></pre>
    <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px;
      margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span
        style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe
        UI,Arial,sans-serif'; color:#000000;">[ ] marks optional
        components<br>
      </span></p>
    <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px;
      margin-right:0px; -qt-block-indent:0; text-indent:0px;
      background-color:#f6f6f6;"><span style="
        font-family:'Lato,Ubuntu,Lucida Grande,Segoe
        UI,Arial,sans-serif'; font-size:medium; font-weight:600;
        color:#93b023; background-color:#f6f6f6;">Arguments</span></p>
    <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px;
      margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span
        style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe
        UI,Arial,sans-serif'; color:#000000;"><br>
      </span><span style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe
        UI,Arial,sans-serif'; font-style:italic; color:#000000;">WHEN
        condition</span><span style=" font-family:'Lato,Ubuntu,Lucida
        Grande,Segoe UI,Arial,sans-serif'; color:#000000;"> - The
        condition expression to evaluate. <br>
        <br>
      </span><span style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe
        UI,Arial,sans-serif'; font-style:italic; color:#000000;">THEN
        result</span><span style=" font-family:'Lato,Ubuntu,Lucida
        Grande,Segoe UI,Arial,sans-serif'; color:#000000;"> - If </span><span
        style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe
        UI,Arial,sans-serif'; font-style:italic; color:#000000;">condition</span><span
        style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe
        UI,Arial,sans-serif'; color:#000000;"> evaluates to True then </span><span
        style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe
        UI,Arial,sans-serif'; font-style:italic; color:#000000;">result</span><span
        style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe
        UI,Arial,sans-serif'; color:#000000;"> is evaluated and
        returned. <br>
        <br>
      </span><span style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe
        UI,Arial,sans-serif'; font-style:italic; color:#000000;">ELSE
        result</span><span style=" font-family:'Lato,Ubuntu,Lucida
        Grande,Segoe UI,Arial,sans-serif'; color:#000000;"> - If none of
        the above conditions evaluated to True then </span><span
        style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe
        UI,Arial,sans-serif'; font-style:italic; color:#000000;">result</span><span
        style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe
        UI,Arial,sans-serif'; color:#000000;"> is evaluated and
        returned.<br>
        <br>
      </span></p>
    <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px;
      margin-right:0px; -qt-block-indent:0; text-indent:0px;
      background-color:#f6f6f6;"><span style="
        font-family:'Lato,Ubuntu,Lucida Grande,Segoe
        UI,Arial,sans-serif'; font-size:medium; font-weight:600;
        color:#93b023; background-color:#f6f6f6;">Example</span></p>
    <pre style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; color:#000000;">CASE</span><span style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe UI,Arial,sans-serif'; color:#000000;">
</span><span style=" font-family:'Courier New'; color:#000000;">WHEN </span><span style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe UI,Arial,sans-serif'; font-style:italic; color:#000000;">"ID" = 1 </span><span style=" font-family:'Courier New'; color:#000000;">THEN </span><span style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe UI,Arial,sans-serif'; font-style:italic; color:#000000;">'Yellow'</span><span style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe UI,Arial,sans-serif'; color:#000000;"></span>
<span style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe UI,Arial,sans-serif'; color:#000000;"><span style=" font-family:'Courier New'; color:#000000;">WHEN </span><span style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe UI,Arial,sans-serif'; font-style:italic; color:#000000;">"ID" = 2 </span><span style=" font-family:'Courier New'; color:#000000;">THEN </span><span style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe UI,Arial,sans-serif'; font-style:italic; color:#000000;">'Green'</span><span style=" font-family:'Lato,Ubuntu,Lucida Grande,Segoe UI,Arial,sans-serif'; color:#000000;"></span>
</span><span style=" font-family:'Courier New'; color:#000000;">END</span></pre>
    <div class="moz-signature"><br>
      Hope this helps,<br>
      David<br>
      <br>
      <br>
    </div>
    <div class="moz-cite-prefix">On 8/17/2020 7:20 PM, krishna Ayyala
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CADUrCAh-=k7B3xy9Mwp3V90H+sg5H_+60mG2y0yjQg5=A7ihVQ@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">I have the following attribute table with two
        fields ID and ID2<br>
        <div>
          <div><img src="cid:part1.5DA66014.78A4D187@sover.net"
              alt="image.png" class="" width="414" height="418"><br>
          </div>
        </div>
        <div><br>
        </div>
        <div>What expression can I use within the field calculator so
          that, I can fill the values for ID2 as below?</div>
        <div><br>
        </div>
        <div>
          <table style="border-collapse:collapse;width:110pt"
            width="146" cellspacing="0" cellpadding="0" border="0">
            <colgroup><col style="width:48pt" width="64"> <col
                style="width:62pt" width="82"> </colgroup><tbody>
              <tr style="height:15pt" height="20">
                <td class="gmail-xl63"
                  style="height:15pt;width:48pt;text-align:center;border:0.5pt
                  solid
windowtext;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri,sans-serif;vertical-align:bottom;white-space:nowrap"
                  width="64" height="20">ID</td>
                <td class="gmail-xl63"
                  style="border-left:none;width:62pt;text-align:center;border-top:0.5pt
                  solid windowtext;border-right:0.5pt solid
                  windowtext;border-bottom:0.5pt solid
windowtext;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri,sans-serif;vertical-align:bottom;white-space:nowrap"
                  width="82">ID2</td>
              </tr>
              <tr style="height:15pt" height="20">
                <td class="gmail-xl63"
                  style="height:15pt;border-top:none;text-align:center;border-right:0.5pt
                  solid windowtext;border-bottom:0.5pt solid
                  windowtext;border-left:0.5pt solid
windowtext;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri,sans-serif;vertical-align:bottom;white-space:nowrap"
                  height="20">1</td>
                <td class="gmail-xl63"
style="border-top:none;border-left:none;text-align:center;border-right:0.5pt
                  solid windowtext;border-bottom:0.5pt solid
windowtext;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri,sans-serif;vertical-align:bottom;white-space:nowrap">Yellow</td>
              </tr>
              <tr style="height:15pt" height="20">
                <td class="gmail-xl63"
                  style="height:15pt;border-top:none;text-align:center;border-right:0.5pt
                  solid windowtext;border-bottom:0.5pt solid
                  windowtext;border-left:0.5pt solid
windowtext;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri,sans-serif;vertical-align:bottom;white-space:nowrap"
                  height="20">2</td>
                <td class="gmail-xl63"
style="border-top:none;border-left:none;text-align:center;border-right:0.5pt
                  solid windowtext;border-bottom:0.5pt solid
windowtext;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri,sans-serif;vertical-align:bottom;white-space:nowrap">Green </td>
              </tr>
              <tr style="height:15pt" height="20">
                <td class="gmail-xl63"
                  style="height:15pt;border-top:none;text-align:center;border-right:0.5pt
                  solid windowtext;border-bottom:0.5pt solid
                  windowtext;border-left:0.5pt solid
windowtext;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri,sans-serif;vertical-align:bottom;white-space:nowrap"
                  height="20">3</td>
                <td class="gmail-xl63"
style="border-top:none;border-left:none;text-align:center;border-right:0.5pt
                  solid windowtext;border-bottom:0.5pt solid
windowtext;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri,sans-serif;vertical-align:bottom;white-space:nowrap">White</td>
              </tr>
              <tr style="height:15pt" height="20">
                <td class="gmail-xl63"
                  style="height:15pt;border-top:none;text-align:center;border-right:0.5pt
                  solid windowtext;border-bottom:0.5pt solid
                  windowtext;border-left:0.5pt solid
windowtext;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri,sans-serif;vertical-align:bottom;white-space:nowrap"
                  height="20">4</td>
                <td class="gmail-xl63"
style="border-top:none;border-left:none;text-align:center;border-right:0.5pt
                  solid windowtext;border-bottom:0.5pt solid
windowtext;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri,sans-serif;vertical-align:bottom;white-space:nowrap">Blue</td>
              </tr>
              <tr style="height:15pt" height="20">
                <td class="gmail-xl63"
                  style="height:15pt;border-top:none;text-align:center;border-right:0.5pt
                  solid windowtext;border-bottom:0.5pt solid
                  windowtext;border-left:0.5pt solid
windowtext;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri,sans-serif;vertical-align:bottom;white-space:nowrap"
                  height="20">5</td>
                <td class="gmail-xl63"
style="border-top:none;border-left:none;text-align:center;border-right:0.5pt
                  solid windowtext;border-bottom:0.5pt solid
windowtext;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri,sans-serif;vertical-align:bottom;white-space:nowrap">Orange</td>
              </tr>
              <tr style="height:15pt" height="20">
                <td class="gmail-xl63"
                  style="height:15pt;border-top:none;text-align:center;border-right:0.5pt
                  solid windowtext;border-bottom:0.5pt solid
                  windowtext;border-left:0.5pt solid
windowtext;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri,sans-serif;vertical-align:bottom;white-space:nowrap"
                  height="20">6</td>
                <td class="gmail-xl63"
style="border-top:none;border-left:none;text-align:center;border-right:0.5pt
                  solid windowtext;border-bottom:0.5pt solid
windowtext;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri,sans-serif;vertical-align:bottom;white-space:nowrap">Brown</td>
              </tr>
              <tr style="height:15pt" height="20">
                <td class="gmail-xl63"
                  style="height:15pt;border-top:none;text-align:center;border-right:0.5pt
                  solid windowtext;border-bottom:0.5pt solid
                  windowtext;border-left:0.5pt solid
windowtext;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri,sans-serif;vertical-align:bottom;white-space:nowrap"
                  height="20">7</td>
                <td class="gmail-xl63"
style="border-top:none;border-left:none;text-align:center;border-right:0.5pt
                  solid windowtext;border-bottom:0.5pt solid
windowtext;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri,sans-serif;vertical-align:bottom;white-space:nowrap">Light
                  Blue</td>
              </tr>
              <tr style="height:15pt" height="20">
                <td class="gmail-xl63"
                  style="height:15pt;border-top:none;text-align:center;border-right:0.5pt
                  solid windowtext;border-bottom:0.5pt solid
                  windowtext;border-left:0.5pt solid
windowtext;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri,sans-serif;vertical-align:bottom;white-space:nowrap"
                  height="20">8</td>
                <td class="gmail-xl63"
style="border-top:none;border-left:none;text-align:center;border-right:0.5pt
                  solid windowtext;border-bottom:0.5pt solid
windowtext;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri,sans-serif;vertical-align:bottom;white-space:nowrap">Light
                  Yellow</td>
              </tr>
              <tr style="height:15pt" height="20">
                <td class="gmail-xl63"
                  style="height:15pt;border-top:none;text-align:center;border-right:0.5pt
                  solid windowtext;border-bottom:0.5pt solid
                  windowtext;border-left:0.5pt solid
windowtext;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri,sans-serif;vertical-align:bottom;white-space:nowrap"
                  height="20">9</td>
                <td class="gmail-xl63"
style="border-top:none;border-left:none;text-align:center;border-right:0.5pt
                  solid windowtext;border-bottom:0.5pt solid
windowtext;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri,sans-serif;vertical-align:bottom;white-space:nowrap">Light
                  Green</td>
              </tr>
            </tbody>
          </table>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-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="https://lists.osgeo.org/mailman/listinfo/qgis-user">https://lists.osgeo.org/mailman/listinfo/qgis-user</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-user">https://lists.osgeo.org/mailman/listinfo/qgis-user</a></pre>
    </blockquote>
  </body>
</html>