How do I get this query to work in the field calcuator in QGIS 3.2?












4















I have a geopackage file which contains point data with column of 'depth of cover' and score. In the score column I am using the field calculation to create an expression so that any number less than 0.5 in the depth of cover column would be represented as a 1 and anything in between 0.6 to 5.0 would be represented as a 2, and anything greater than 5.1 would be a 3 in the score column. This is the expression I have used:



CASE
WHEN "Depth of cover" <=0.5 THEN 1
WHEN "Depth of cover" >=0.6 <=5.0 THEN 2
WHEN "Depth of cover">=5.1 THEN 3 End


I can get the 1 and 3 values to work but not 2. I know I have the expression wrong at this point because I'm doing a range rather than a less than or greater.



Following on from this if I wanted to change the 1 to a High 2 to medium and 3 to Low how would I do this as I get Column 'High' not found.










share|improve this question

























  • I think your formula misses an AND in the second WHEN-clause.

    – Erik
    10 hours ago
















4















I have a geopackage file which contains point data with column of 'depth of cover' and score. In the score column I am using the field calculation to create an expression so that any number less than 0.5 in the depth of cover column would be represented as a 1 and anything in between 0.6 to 5.0 would be represented as a 2, and anything greater than 5.1 would be a 3 in the score column. This is the expression I have used:



CASE
WHEN "Depth of cover" <=0.5 THEN 1
WHEN "Depth of cover" >=0.6 <=5.0 THEN 2
WHEN "Depth of cover">=5.1 THEN 3 End


I can get the 1 and 3 values to work but not 2. I know I have the expression wrong at this point because I'm doing a range rather than a less than or greater.



Following on from this if I wanted to change the 1 to a High 2 to medium and 3 to Low how would I do this as I get Column 'High' not found.










share|improve this question

























  • I think your formula misses an AND in the second WHEN-clause.

    – Erik
    10 hours ago














4












4








4








I have a geopackage file which contains point data with column of 'depth of cover' and score. In the score column I am using the field calculation to create an expression so that any number less than 0.5 in the depth of cover column would be represented as a 1 and anything in between 0.6 to 5.0 would be represented as a 2, and anything greater than 5.1 would be a 3 in the score column. This is the expression I have used:



CASE
WHEN "Depth of cover" <=0.5 THEN 1
WHEN "Depth of cover" >=0.6 <=5.0 THEN 2
WHEN "Depth of cover">=5.1 THEN 3 End


I can get the 1 and 3 values to work but not 2. I know I have the expression wrong at this point because I'm doing a range rather than a less than or greater.



Following on from this if I wanted to change the 1 to a High 2 to medium and 3 to Low how would I do this as I get Column 'High' not found.










share|improve this question
















I have a geopackage file which contains point data with column of 'depth of cover' and score. In the score column I am using the field calculation to create an expression so that any number less than 0.5 in the depth of cover column would be represented as a 1 and anything in between 0.6 to 5.0 would be represented as a 2, and anything greater than 5.1 would be a 3 in the score column. This is the expression I have used:



CASE
WHEN "Depth of cover" <=0.5 THEN 1
WHEN "Depth of cover" >=0.6 <=5.0 THEN 2
WHEN "Depth of cover">=5.1 THEN 3 End


I can get the 1 and 3 values to work but not 2. I know I have the expression wrong at this point because I'm doing a range rather than a less than or greater.



Following on from this if I wanted to change the 1 to a High 2 to medium and 3 to Low how would I do this as I get Column 'High' not found.







qgis field-calculator






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 10 hours ago









BERA

15.6k52042




15.6k52042










asked 10 hours ago









WoodyWoody

484




484













  • I think your formula misses an AND in the second WHEN-clause.

    – Erik
    10 hours ago



















  • I think your formula misses an AND in the second WHEN-clause.

    – Erik
    10 hours ago

















I think your formula misses an AND in the second WHEN-clause.

– Erik
10 hours ago





I think your formula misses an AND in the second WHEN-clause.

– Erik
10 hours ago










1 Answer
1






active

oldest

votes


















10














Try this (I correct bounds too) :



CASE
WHEN "Depth of cover" <= 0.5 THEN 1
WHEN "Depth of cover" > 0.5 AND "Depth of cover" <= 5.0 THEN 2
WHEN "Depth of cover" > 5.0 THEN 3
END


For the second part, create a string field and update it with :



CASE
WHEN "Depth of cover" <= 0.5 THEN 'High'
WHEN "Depth of cover" > 0.5 AND "Depth of cover" <= 5.0 THEN 'Medium'
WHEN "Depth of cover" > 5.0 THEN 'Low'
END





share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "79"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f311247%2fhow-do-i-get-this-query-to-work-in-the-field-calcuator-in-qgis-3-2%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    10














    Try this (I correct bounds too) :



    CASE
    WHEN "Depth of cover" <= 0.5 THEN 1
    WHEN "Depth of cover" > 0.5 AND "Depth of cover" <= 5.0 THEN 2
    WHEN "Depth of cover" > 5.0 THEN 3
    END


    For the second part, create a string field and update it with :



    CASE
    WHEN "Depth of cover" <= 0.5 THEN 'High'
    WHEN "Depth of cover" > 0.5 AND "Depth of cover" <= 5.0 THEN 'Medium'
    WHEN "Depth of cover" > 5.0 THEN 'Low'
    END





    share|improve this answer




























      10














      Try this (I correct bounds too) :



      CASE
      WHEN "Depth of cover" <= 0.5 THEN 1
      WHEN "Depth of cover" > 0.5 AND "Depth of cover" <= 5.0 THEN 2
      WHEN "Depth of cover" > 5.0 THEN 3
      END


      For the second part, create a string field and update it with :



      CASE
      WHEN "Depth of cover" <= 0.5 THEN 'High'
      WHEN "Depth of cover" > 0.5 AND "Depth of cover" <= 5.0 THEN 'Medium'
      WHEN "Depth of cover" > 5.0 THEN 'Low'
      END





      share|improve this answer


























        10












        10








        10







        Try this (I correct bounds too) :



        CASE
        WHEN "Depth of cover" <= 0.5 THEN 1
        WHEN "Depth of cover" > 0.5 AND "Depth of cover" <= 5.0 THEN 2
        WHEN "Depth of cover" > 5.0 THEN 3
        END


        For the second part, create a string field and update it with :



        CASE
        WHEN "Depth of cover" <= 0.5 THEN 'High'
        WHEN "Depth of cover" > 0.5 AND "Depth of cover" <= 5.0 THEN 'Medium'
        WHEN "Depth of cover" > 5.0 THEN 'Low'
        END





        share|improve this answer













        Try this (I correct bounds too) :



        CASE
        WHEN "Depth of cover" <= 0.5 THEN 1
        WHEN "Depth of cover" > 0.5 AND "Depth of cover" <= 5.0 THEN 2
        WHEN "Depth of cover" > 5.0 THEN 3
        END


        For the second part, create a string field and update it with :



        CASE
        WHEN "Depth of cover" <= 0.5 THEN 'High'
        WHEN "Depth of cover" > 0.5 AND "Depth of cover" <= 5.0 THEN 'Medium'
        WHEN "Depth of cover" > 5.0 THEN 'Low'
        END






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 10 hours ago









        J. MonticoloJ. Monticolo

        511111




        511111






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f311247%2fhow-do-i-get-this-query-to-work-in-the-field-calcuator-in-qgis-3-2%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Callistus I

            Tabula Rosettana

            How to label and detect the document text images