Concatenate five fields where some may be NULL
I have a trench containing five types of ducts.
I have created fields the trenches: Type1, Type2, Type3, ...
The values in each field are the numbers of each type of duct that the trench contains.
eg. lets say that one trench contains 2 ducts of type one and one duct of type 2, then I would like to label it something like this: 2xType1,Type2
The other types are NULL. How can I write a compact expression to handle this?
qgis null concatenation
add a comment |
I have a trench containing five types of ducts.
I have created fields the trenches: Type1, Type2, Type3, ...
The values in each field are the numbers of each type of duct that the trench contains.
eg. lets say that one trench contains 2 ducts of type one and one duct of type 2, then I would like to label it something like this: 2xType1,Type2
The other types are NULL. How can I write a compact expression to handle this?
qgis null concatenation
3
What have you tried? You should be able to use the coalesce function in a label expression to hande nulls
– BERA
Feb 28 at 10:27
add a comment |
I have a trench containing five types of ducts.
I have created fields the trenches: Type1, Type2, Type3, ...
The values in each field are the numbers of each type of duct that the trench contains.
eg. lets say that one trench contains 2 ducts of type one and one duct of type 2, then I would like to label it something like this: 2xType1,Type2
The other types are NULL. How can I write a compact expression to handle this?
qgis null concatenation
I have a trench containing five types of ducts.
I have created fields the trenches: Type1, Type2, Type3, ...
The values in each field are the numbers of each type of duct that the trench contains.
eg. lets say that one trench contains 2 ducts of type one and one duct of type 2, then I would like to label it something like this: 2xType1,Type2
The other types are NULL. How can I write a compact expression to handle this?
qgis null concatenation
qgis null concatenation
edited Feb 28 at 19:55
underdark♦
69.1k13178346
69.1k13178346
asked Feb 28 at 10:17
SundrawSundraw
41
41
3
What have you tried? You should be able to use the coalesce function in a label expression to hande nulls
– BERA
Feb 28 at 10:27
add a comment |
3
What have you tried? You should be able to use the coalesce function in a label expression to hande nulls
– BERA
Feb 28 at 10:27
3
3
What have you tried? You should be able to use the coalesce function in a label expression to hande nulls
– BERA
Feb 28 at 10:27
What have you tried? You should be able to use the coalesce function in a label expression to hande nulls
– BERA
Feb 28 at 10:27
add a comment |
1 Answer
1
active
oldest
votes
Maybe use something like the following:
replace(
if("Type 1" > 0 and "Type 2" > 0, "Type 1" || 'x Type1, ' || "Type 2" || 'x Type2',
if("Type 1" = 0 or "Type 1" IS NULL, "Type 2" || 'x Type2',
if("Type 2" = 0 or "Type 2" IS NULL, "Type 1" || 'x Type1', ''))), '1x', '')
add a comment |
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
});
}
});
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%2f313873%2fconcatenate-five-fields-where-some-may-be-null%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
Maybe use something like the following:
replace(
if("Type 1" > 0 and "Type 2" > 0, "Type 1" || 'x Type1, ' || "Type 2" || 'x Type2',
if("Type 1" = 0 or "Type 1" IS NULL, "Type 2" || 'x Type2',
if("Type 2" = 0 or "Type 2" IS NULL, "Type 1" || 'x Type1', ''))), '1x', '')
add a comment |
Maybe use something like the following:
replace(
if("Type 1" > 0 and "Type 2" > 0, "Type 1" || 'x Type1, ' || "Type 2" || 'x Type2',
if("Type 1" = 0 or "Type 1" IS NULL, "Type 2" || 'x Type2',
if("Type 2" = 0 or "Type 2" IS NULL, "Type 1" || 'x Type1', ''))), '1x', '')
add a comment |
Maybe use something like the following:
replace(
if("Type 1" > 0 and "Type 2" > 0, "Type 1" || 'x Type1, ' || "Type 2" || 'x Type2',
if("Type 1" = 0 or "Type 1" IS NULL, "Type 2" || 'x Type2',
if("Type 2" = 0 or "Type 2" IS NULL, "Type 1" || 'x Type1', ''))), '1x', '')
Maybe use something like the following:
replace(
if("Type 1" > 0 and "Type 2" > 0, "Type 1" || 'x Type1, ' || "Type 2" || 'x Type2',
if("Type 1" = 0 or "Type 1" IS NULL, "Type 2" || 'x Type2',
if("Type 2" = 0 or "Type 2" IS NULL, "Type 1" || 'x Type1', ''))), '1x', '')
edited Feb 28 at 15:54
answered Feb 28 at 11:00
JosephJoseph
58.5k7101206
58.5k7101206
add a comment |
add a comment |
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.
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%2f313873%2fconcatenate-five-fields-where-some-may-be-null%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
3
What have you tried? You should be able to use the coalesce function in a label expression to hande nulls
– BERA
Feb 28 at 10:27