QGIS 2.18 label by expression concatenate field stringsHow to use buffer() in QGIS Value Relation fieldHow to calculate percentages using QGIS field calculator expression?Limiting available values in dropdown field of QGIS form according to value selected in previous field?QGIS Multiple CASE WHEN/THEN Statements for Expression Based LabelsCan I make Points-in-polygon output to the attribute table of polygon layer?Splitting text attribute using conditional function QGIS 2.18.13Concatenate Label Values Fails to Calculate AggregateCreating new field with values from different fields QGISAdding text to label expression in QGIS?Labeling expressions on AGOL with Arcade for certain features

Is this homebrew Wind Wave spell balanced?

How much cash can I safely carry into the USA and avoid civil forfeiture?

What is Niska's accent?

Can I spend a night at Vancouver then take a flight to my college in Toronto as an international student?

Why isn't the definition of absolute value applied when squaring a radical containing a variable?

How can I practically buy stocks?

Don’t seats that recline flat defeat the purpose of having seatbelts?

Why do Computer Science majors learn Calculus?

Unexpected email from Yorkshire Bank

Normal Map bad shading in Rendered display

Binary Numbers Magic Trick

Is there a way to get a compiler for the original B programming language?

How to get a plain text file version of a CP/M .BAS (M-BASIC) program?

Can someone publish a story that happened to you?

In order to check if a field is required or not, is the result of isNillable method sufficient?

Realistic Necromancy?

How do I deal with a coworker that keeps asking to make small superficial changes to a report, and it is seriously triggering my anxiety?

How to verbalise code in Mathematica?

A ​Note ​on ​N!

Fizzy, soft, pop and still drinks

How to reduce LED flash rate (frequency)

Combinable filters

Exchange,swap or switch

What's the polite way to say "I need to urinate"?



QGIS 2.18 label by expression concatenate field strings


How to use buffer() in QGIS Value Relation fieldHow to calculate percentages using QGIS field calculator expression?Limiting available values in dropdown field of QGIS form according to value selected in previous field?QGIS Multiple CASE WHEN/THEN Statements for Expression Based LabelsCan I make Points-in-polygon output to the attribute table of polygon layer?Splitting text attribute using conditional function QGIS 2.18.13Concatenate Label Values Fails to Calculate AggregateCreating new field with values from different fields QGISAdding text to label expression in QGIS?Labeling expressions on AGOL with Arcade for certain features






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















For a building layer I have an attribute table with several fields for the building type where data was entered with a manually created form using checkboxes. Example:



Production: 1 = (yes), 0 = (no)
Office: 1 = (yes), 0 = (no)
Storage: 1 = (yes), 0 = (no)


and so on...



Now I want to label this layer with first letter of the respective building type. Like e.g: Production = P, Office = O, Storage = S and so on...



In case its only only one type its easy. I create a new field and use an expression like this:



CASE WHEN "Production" = 1 THEN 'P' ELSE '' END


But many buildings refer to multiple types, so I'd like to have expression that wraps everything up. It should check the state of the check box fields and concatenate the respective letters in a new field:
Examples:



P/S

O/S

P/O

P/O/S


How to do so?










share|improve this question
























  • Are the slashes necessary?

    – Erik
    Apr 24 at 11:58











  • Well, would be nice to have. If it gets too complicated like that, only spacing might be sufficient as well

    – Philippo Storino
    Apr 24 at 12:01

















2















For a building layer I have an attribute table with several fields for the building type where data was entered with a manually created form using checkboxes. Example:



Production: 1 = (yes), 0 = (no)
Office: 1 = (yes), 0 = (no)
Storage: 1 = (yes), 0 = (no)


and so on...



Now I want to label this layer with first letter of the respective building type. Like e.g: Production = P, Office = O, Storage = S and so on...



In case its only only one type its easy. I create a new field and use an expression like this:



CASE WHEN "Production" = 1 THEN 'P' ELSE '' END


But many buildings refer to multiple types, so I'd like to have expression that wraps everything up. It should check the state of the check box fields and concatenate the respective letters in a new field:
Examples:



P/S

O/S

P/O

P/O/S


How to do so?










share|improve this question
























  • Are the slashes necessary?

    – Erik
    Apr 24 at 11:58











  • Well, would be nice to have. If it gets too complicated like that, only spacing might be sufficient as well

    – Philippo Storino
    Apr 24 at 12:01













2












2








2








For a building layer I have an attribute table with several fields for the building type where data was entered with a manually created form using checkboxes. Example:



Production: 1 = (yes), 0 = (no)
Office: 1 = (yes), 0 = (no)
Storage: 1 = (yes), 0 = (no)


and so on...



Now I want to label this layer with first letter of the respective building type. Like e.g: Production = P, Office = O, Storage = S and so on...



In case its only only one type its easy. I create a new field and use an expression like this:



CASE WHEN "Production" = 1 THEN 'P' ELSE '' END


But many buildings refer to multiple types, so I'd like to have expression that wraps everything up. It should check the state of the check box fields and concatenate the respective letters in a new field:
Examples:



P/S

O/S

P/O

P/O/S


How to do so?










share|improve this question
















For a building layer I have an attribute table with several fields for the building type where data was entered with a manually created form using checkboxes. Example:



Production: 1 = (yes), 0 = (no)
Office: 1 = (yes), 0 = (no)
Storage: 1 = (yes), 0 = (no)


and so on...



Now I want to label this layer with first letter of the respective building type. Like e.g: Production = P, Office = O, Storage = S and so on...



In case its only only one type its easy. I create a new field and use an expression like this:



CASE WHEN "Production" = 1 THEN 'P' ELSE '' END


But many buildings refer to multiple types, so I'd like to have expression that wraps everything up. It should check the state of the check box fields and concatenate the respective letters in a new field:
Examples:



P/S

O/S

P/O

P/O/S


How to do so?







qgis labeling expression concatenation






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 24 at 12:07









JGH

13.9k21339




13.9k21339










asked Apr 24 at 11:51









Philippo StorinoPhilippo Storino

365




365












  • Are the slashes necessary?

    – Erik
    Apr 24 at 11:58











  • Well, would be nice to have. If it gets too complicated like that, only spacing might be sufficient as well

    – Philippo Storino
    Apr 24 at 12:01

















  • Are the slashes necessary?

    – Erik
    Apr 24 at 11:58











  • Well, would be nice to have. If it gets too complicated like that, only spacing might be sufficient as well

    – Philippo Storino
    Apr 24 at 12:01
















Are the slashes necessary?

– Erik
Apr 24 at 11:58





Are the slashes necessary?

– Erik
Apr 24 at 11:58













Well, would be nice to have. If it gets too complicated like that, only spacing might be sufficient as well

– Philippo Storino
Apr 24 at 12:01





Well, would be nice to have. If it gets too complicated like that, only spacing might be sufficient as well

– Philippo Storino
Apr 24 at 12:01










1 Answer
1






active

oldest

votes


















3














You can evaluate each condition using if(), combine the outputs using ||, and remove the last slash using a regex expression:



regexp_replace( if("production"=1,'P/','') || if("office"=1,'O/','') || if("storage"=1,'S/',''),'/$','')





share|improve this answer























  • So '/$' finds me the last / - or any other character? Nice to know.

    – Erik
    Apr 24 at 12:17











  • That worked prefectly! Thanks a lot!!!

    – Philippo Storino
    Apr 24 at 12:19






  • 2





    @Erik $ is for end of line, / is for /, so the combination looks for a / followed by end of line (i.e the last one only)

    – JGH
    Apr 24 at 12:21












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%2f320717%2fqgis-2-18-label-by-expression-concatenate-field-strings%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









3














You can evaluate each condition using if(), combine the outputs using ||, and remove the last slash using a regex expression:



regexp_replace( if("production"=1,'P/','') || if("office"=1,'O/','') || if("storage"=1,'S/',''),'/$','')





share|improve this answer























  • So '/$' finds me the last / - or any other character? Nice to know.

    – Erik
    Apr 24 at 12:17











  • That worked prefectly! Thanks a lot!!!

    – Philippo Storino
    Apr 24 at 12:19






  • 2





    @Erik $ is for end of line, / is for /, so the combination looks for a / followed by end of line (i.e the last one only)

    – JGH
    Apr 24 at 12:21
















3














You can evaluate each condition using if(), combine the outputs using ||, and remove the last slash using a regex expression:



regexp_replace( if("production"=1,'P/','') || if("office"=1,'O/','') || if("storage"=1,'S/',''),'/$','')





share|improve this answer























  • So '/$' finds me the last / - or any other character? Nice to know.

    – Erik
    Apr 24 at 12:17











  • That worked prefectly! Thanks a lot!!!

    – Philippo Storino
    Apr 24 at 12:19






  • 2





    @Erik $ is for end of line, / is for /, so the combination looks for a / followed by end of line (i.e the last one only)

    – JGH
    Apr 24 at 12:21














3












3








3







You can evaluate each condition using if(), combine the outputs using ||, and remove the last slash using a regex expression:



regexp_replace( if("production"=1,'P/','') || if("office"=1,'O/','') || if("storage"=1,'S/',''),'/$','')





share|improve this answer













You can evaluate each condition using if(), combine the outputs using ||, and remove the last slash using a regex expression:



regexp_replace( if("production"=1,'P/','') || if("office"=1,'O/','') || if("storage"=1,'S/',''),'/$','')






share|improve this answer












share|improve this answer



share|improve this answer










answered Apr 24 at 12:05









JGHJGH

13.9k21339




13.9k21339












  • So '/$' finds me the last / - or any other character? Nice to know.

    – Erik
    Apr 24 at 12:17











  • That worked prefectly! Thanks a lot!!!

    – Philippo Storino
    Apr 24 at 12:19






  • 2





    @Erik $ is for end of line, / is for /, so the combination looks for a / followed by end of line (i.e the last one only)

    – JGH
    Apr 24 at 12:21


















  • So '/$' finds me the last / - or any other character? Nice to know.

    – Erik
    Apr 24 at 12:17











  • That worked prefectly! Thanks a lot!!!

    – Philippo Storino
    Apr 24 at 12:19






  • 2





    @Erik $ is for end of line, / is for /, so the combination looks for a / followed by end of line (i.e the last one only)

    – JGH
    Apr 24 at 12:21

















So '/$' finds me the last / - or any other character? Nice to know.

– Erik
Apr 24 at 12:17





So '/$' finds me the last / - or any other character? Nice to know.

– Erik
Apr 24 at 12:17













That worked prefectly! Thanks a lot!!!

– Philippo Storino
Apr 24 at 12:19





That worked prefectly! Thanks a lot!!!

– Philippo Storino
Apr 24 at 12:19




2




2





@Erik $ is for end of line, / is for /, so the combination looks for a / followed by end of line (i.e the last one only)

– JGH
Apr 24 at 12:21






@Erik $ is for end of line, / is for /, so the combination looks for a / followed by end of line (i.e the last one only)

– JGH
Apr 24 at 12:21


















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%2f320717%2fqgis-2-18-label-by-expression-concatenate-field-strings%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

How does Billy Russo acquire his 'Jigsaw' mask? Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Favourite questions and answers from the 1st quarter of 2019Why does Bane wear the mask?Why does Kylo Ren wear a mask?Why did Captain America remove his mask while fighting Batroc the Leaper?How did the OA acquire her wisdom?Is Billy Breckenridge gay?How does Adrian Toomes hide his earnings from the IRS?What is the state of affairs on Nootka Sound by the end of season 1?How did Tia Dalma acquire Captain Barbossa's body?How is one “Deemed Worthy”, to acquire the Greatsword “Dawn”?How did Karen acquire the handgun?

Личност Атрибути на личността | Литература и източници | НавигацияРаждането на личносттаредактиратередактирате

A sequel to Domino's tragic life Why Christmas is for Friends Cold comfort at Charles' padSad farewell for Lady JanePS Most watched News videos