Weighted values of the field in QGIS

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












In QGIS in the Attribute Table, there is a field with values.



For this field, I need to calculate the sum of all its values and divide by the number of values that are not equal to NULL.



Afterwards, I need to create a new field, where each value of the original field will be divided into the previously calculated (the sum of all its values and divided by the number of values).



Is it possible to do this with the function editor in the Field Calculator (as this action will be repeated more than once)?










share|improve this question









New contributor




Екатерина Уварова is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • it would be highly appreciated if you can provide us with a sample of your data and your desired output, alternatively you may describe it. For instance, my values are integers or real, and my output should look like something.
    – Taras
    3 hours ago














up vote
1
down vote

favorite












In QGIS in the Attribute Table, there is a field with values.



For this field, I need to calculate the sum of all its values and divide by the number of values that are not equal to NULL.



Afterwards, I need to create a new field, where each value of the original field will be divided into the previously calculated (the sum of all its values and divided by the number of values).



Is it possible to do this with the function editor in the Field Calculator (as this action will be repeated more than once)?










share|improve this question









New contributor




Екатерина Уварова is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • it would be highly appreciated if you can provide us with a sample of your data and your desired output, alternatively you may describe it. For instance, my values are integers or real, and my output should look like something.
    – Taras
    3 hours ago












up vote
1
down vote

favorite









up vote
1
down vote

favorite











In QGIS in the Attribute Table, there is a field with values.



For this field, I need to calculate the sum of all its values and divide by the number of values that are not equal to NULL.



Afterwards, I need to create a new field, where each value of the original field will be divided into the previously calculated (the sum of all its values and divided by the number of values).



Is it possible to do this with the function editor in the Field Calculator (as this action will be repeated more than once)?










share|improve this question









New contributor




Екатерина Уварова is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











In QGIS in the Attribute Table, there is a field with values.



For this field, I need to calculate the sum of all its values and divide by the number of values that are not equal to NULL.



Afterwards, I need to create a new field, where each value of the original field will be divided into the previously calculated (the sum of all its values and divided by the number of values).



Is it possible to do this with the function editor in the Field Calculator (as this action will be repeated more than once)?







qgis field-calculator






share|improve this question









New contributor




Екатерина Уварова is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Екатерина Уварова is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 3 hours ago









Taras

1,3081521




1,3081521






New contributor




Екатерина Уварова is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 4 hours ago









Екатерина Уварова

91




91




New contributor




Екатерина Уварова is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Екатерина Уварова is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Екатерина Уварова is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • it would be highly appreciated if you can provide us with a sample of your data and your desired output, alternatively you may describe it. For instance, my values are integers or real, and my output should look like something.
    – Taras
    3 hours ago
















  • it would be highly appreciated if you can provide us with a sample of your data and your desired output, alternatively you may describe it. For instance, my values are integers or real, and my output should look like something.
    – Taras
    3 hours ago















it would be highly appreciated if you can provide us with a sample of your data and your desired output, alternatively you may describe it. For instance, my values are integers or real, and my output should look like something.
– Taras
3 hours ago




it would be highly appreciated if you can provide us with a sample of your data and your desired output, alternatively you may describe it. For instance, my values are integers or real, and my output should look like something.
– Taras
3 hours ago










1 Answer
1






active

oldest

votes

















up vote
4
down vote













First of all, you need to create one additional field in the Attribute Table:




  • "Output", where the calculated new values will be stored (probably a real data type).

Then you need to proceed in Expression dialogue using the following formula



CASE
WHEN "YOUR_FIELD" <> 'NULL' THEN "YOUR_FIELD" / (sum("YOUR_FIELD") / count("YOUR_FIELD"))
ELSE NULL
END



A short example. I do have a field with values, that vary between 3 and 300, and also include 'NULL' values. See the Attribute Table below.



Attribute_Table



In my case, the sum of all values is 544. The number of values that are not equal to 'NULL' is 7.



Then I proceed with a formula in the Expression dialogue with activated Editing mode.



CASE
WHEN "Value" <> 'NULL' THEN "Value" / (sum("Value") / count("Value"))
ELSE NULL
END


Expression_Dialogue



Afterwards, I achieved corresponding new values.



Output




References:



  • Summarizing column in QGIS field calculator?

  • Calculating sum of parts of column based on another column using QGIS Field Calculator?

  • How to group and count attribute data?

  • Elseif Conditional Statement in QGIS Field Calculator





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',
    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
    );



    );






    Екатерина Уварова is a new contributor. Be nice, and check out our Code of Conduct.









     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f301639%2fweighted-values-of-the-field-in-qgis%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    4
    down vote













    First of all, you need to create one additional field in the Attribute Table:




    • "Output", where the calculated new values will be stored (probably a real data type).

    Then you need to proceed in Expression dialogue using the following formula



    CASE
    WHEN "YOUR_FIELD" <> 'NULL' THEN "YOUR_FIELD" / (sum("YOUR_FIELD") / count("YOUR_FIELD"))
    ELSE NULL
    END



    A short example. I do have a field with values, that vary between 3 and 300, and also include 'NULL' values. See the Attribute Table below.



    Attribute_Table



    In my case, the sum of all values is 544. The number of values that are not equal to 'NULL' is 7.



    Then I proceed with a formula in the Expression dialogue with activated Editing mode.



    CASE
    WHEN "Value" <> 'NULL' THEN "Value" / (sum("Value") / count("Value"))
    ELSE NULL
    END


    Expression_Dialogue



    Afterwards, I achieved corresponding new values.



    Output




    References:



    • Summarizing column in QGIS field calculator?

    • Calculating sum of parts of column based on another column using QGIS Field Calculator?

    • How to group and count attribute data?

    • Elseif Conditional Statement in QGIS Field Calculator





    share|improve this answer


























      up vote
      4
      down vote













      First of all, you need to create one additional field in the Attribute Table:




      • "Output", where the calculated new values will be stored (probably a real data type).

      Then you need to proceed in Expression dialogue using the following formula



      CASE
      WHEN "YOUR_FIELD" <> 'NULL' THEN "YOUR_FIELD" / (sum("YOUR_FIELD") / count("YOUR_FIELD"))
      ELSE NULL
      END



      A short example. I do have a field with values, that vary between 3 and 300, and also include 'NULL' values. See the Attribute Table below.



      Attribute_Table



      In my case, the sum of all values is 544. The number of values that are not equal to 'NULL' is 7.



      Then I proceed with a formula in the Expression dialogue with activated Editing mode.



      CASE
      WHEN "Value" <> 'NULL' THEN "Value" / (sum("Value") / count("Value"))
      ELSE NULL
      END


      Expression_Dialogue



      Afterwards, I achieved corresponding new values.



      Output




      References:



      • Summarizing column in QGIS field calculator?

      • Calculating sum of parts of column based on another column using QGIS Field Calculator?

      • How to group and count attribute data?

      • Elseif Conditional Statement in QGIS Field Calculator





      share|improve this answer
























        up vote
        4
        down vote










        up vote
        4
        down vote









        First of all, you need to create one additional field in the Attribute Table:




        • "Output", where the calculated new values will be stored (probably a real data type).

        Then you need to proceed in Expression dialogue using the following formula



        CASE
        WHEN "YOUR_FIELD" <> 'NULL' THEN "YOUR_FIELD" / (sum("YOUR_FIELD") / count("YOUR_FIELD"))
        ELSE NULL
        END



        A short example. I do have a field with values, that vary between 3 and 300, and also include 'NULL' values. See the Attribute Table below.



        Attribute_Table



        In my case, the sum of all values is 544. The number of values that are not equal to 'NULL' is 7.



        Then I proceed with a formula in the Expression dialogue with activated Editing mode.



        CASE
        WHEN "Value" <> 'NULL' THEN "Value" / (sum("Value") / count("Value"))
        ELSE NULL
        END


        Expression_Dialogue



        Afterwards, I achieved corresponding new values.



        Output




        References:



        • Summarizing column in QGIS field calculator?

        • Calculating sum of parts of column based on another column using QGIS Field Calculator?

        • How to group and count attribute data?

        • Elseif Conditional Statement in QGIS Field Calculator





        share|improve this answer














        First of all, you need to create one additional field in the Attribute Table:




        • "Output", where the calculated new values will be stored (probably a real data type).

        Then you need to proceed in Expression dialogue using the following formula



        CASE
        WHEN "YOUR_FIELD" <> 'NULL' THEN "YOUR_FIELD" / (sum("YOUR_FIELD") / count("YOUR_FIELD"))
        ELSE NULL
        END



        A short example. I do have a field with values, that vary between 3 and 300, and also include 'NULL' values. See the Attribute Table below.



        Attribute_Table



        In my case, the sum of all values is 544. The number of values that are not equal to 'NULL' is 7.



        Then I proceed with a formula in the Expression dialogue with activated Editing mode.



        CASE
        WHEN "Value" <> 'NULL' THEN "Value" / (sum("Value") / count("Value"))
        ELSE NULL
        END


        Expression_Dialogue



        Afterwards, I achieved corresponding new values.



        Output




        References:



        • Summarizing column in QGIS field calculator?

        • Calculating sum of parts of column based on another column using QGIS Field Calculator?

        • How to group and count attribute data?

        • Elseif Conditional Statement in QGIS Field Calculator






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 2 hours ago

























        answered 3 hours ago









        Taras

        1,3081521




        1,3081521




















            Екатерина Уварова is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            Екатерина Уварова is a new contributor. Be nice, and check out our Code of Conduct.












            Екатерина Уварова is a new contributor. Be nice, and check out our Code of Conduct.











            Екатерина Уварова is a new contributor. Be nice, and check out our Code of Conduct.













             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f301639%2fweighted-values-of-the-field-in-qgis%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            What does second last employer means? [closed]

            List of Gilmore Girls characters

            Confectionery