Weighted values of the field in QGIS
up vote
2
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)?
qgis field-calculator
add a comment |
up vote
2
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)?
qgis field-calculator
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
Nov 7 at 7:16
add a comment |
up vote
2
down vote
favorite
up vote
2
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)?
qgis field-calculator
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
qgis field-calculator
edited Nov 7 at 7:04
Taras
1,4661521
1,4661521
asked Nov 7 at 5:51
Екатерина Уварова
242
242
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
Nov 7 at 7:16
add a comment |
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
Nov 7 at 7:16
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
Nov 7 at 7:16
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
Nov 7 at 7:16
add a comment |
1 Answer
1
active
oldest
votes
up vote
6
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.
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
Afterwards, I achieved corresponding new values.
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
- Expressions in QGIS
- Difference between quotation marks ('single' vs “double”) in QGIS
Many thanks for the answer, but my action is repeated very often and therefore I needed to create a function in the function editor. in Expression dialogue I also introduced the formula "Value" / ( sum( "Value" ) / (count( CASE WHEN "Value" >= 1 THEN +1 END)))
– Екатерина Уварова
Nov 9 at 3:45
Processing modeller should solve your issue
– Taras
Nov 9 at 12:16
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
6
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.
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
Afterwards, I achieved corresponding new values.
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
- Expressions in QGIS
- Difference between quotation marks ('single' vs “double”) in QGIS
Many thanks for the answer, but my action is repeated very often and therefore I needed to create a function in the function editor. in Expression dialogue I also introduced the formula "Value" / ( sum( "Value" ) / (count( CASE WHEN "Value" >= 1 THEN +1 END)))
– Екатерина Уварова
Nov 9 at 3:45
Processing modeller should solve your issue
– Taras
Nov 9 at 12:16
add a comment |
up vote
6
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.
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
Afterwards, I achieved corresponding new values.
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
- Expressions in QGIS
- Difference between quotation marks ('single' vs “double”) in QGIS
Many thanks for the answer, but my action is repeated very often and therefore I needed to create a function in the function editor. in Expression dialogue I also introduced the formula "Value" / ( sum( "Value" ) / (count( CASE WHEN "Value" >= 1 THEN +1 END)))
– Екатерина Уварова
Nov 9 at 3:45
Processing modeller should solve your issue
– Taras
Nov 9 at 12:16
add a comment |
up vote
6
down vote
up vote
6
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.
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
Afterwards, I achieved corresponding new values.
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
- Expressions in QGIS
- Difference between quotation marks ('single' vs “double”) in QGIS
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.
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
Afterwards, I achieved corresponding new values.
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
- Expressions in QGIS
- Difference between quotation marks ('single' vs “double”) in QGIS
edited Nov 8 at 13:35
answered Nov 7 at 6:44
Taras
1,4661521
1,4661521
Many thanks for the answer, but my action is repeated very often and therefore I needed to create a function in the function editor. in Expression dialogue I also introduced the formula "Value" / ( sum( "Value" ) / (count( CASE WHEN "Value" >= 1 THEN +1 END)))
– Екатерина Уварова
Nov 9 at 3:45
Processing modeller should solve your issue
– Taras
Nov 9 at 12:16
add a comment |
Many thanks for the answer, but my action is repeated very often and therefore I needed to create a function in the function editor. in Expression dialogue I also introduced the formula "Value" / ( sum( "Value" ) / (count( CASE WHEN "Value" >= 1 THEN +1 END)))
– Екатерина Уварова
Nov 9 at 3:45
Processing modeller should solve your issue
– Taras
Nov 9 at 12:16
Many thanks for the answer, but my action is repeated very often and therefore I needed to create a function in the function editor. in Expression dialogue I also introduced the formula "Value" / ( sum( "Value" ) / (count( CASE WHEN "Value" >= 1 THEN +1 END)))
– Екатерина Уварова
Nov 9 at 3:45
Many thanks for the answer, but my action is repeated very often and therefore I needed to create a function in the function editor. in Expression dialogue I also introduced the formula "Value" / ( sum( "Value" ) / (count( CASE WHEN "Value" >= 1 THEN +1 END)))
– Екатерина Уварова
Nov 9 at 3:45
Processing modeller should solve your issue
– Taras
Nov 9 at 12:16
Processing modeller should solve your issue
– Taras
Nov 9 at 12:16
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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
Nov 7 at 7:16