Labeling polygons with the number of related table entries in QGISWhen labelling polygons, not all labels are displayed - QGIS 1.7.0Detecting densely labelled areas in ArcPy?Two different ways of labeling in QGIS LayouterUsing attribute data for legend labeling in QGIS?QGIS Labeling not workingLabel is appearing two times for some areas. How i can solve the problem, label should be shown one time for one areaIn MapBox Studio, how to create a centred label of a polygon created from shapefile?Label QGIS points layer with auto incrementing number count from 1QGIS 3 Line connecting point to label issue - can not get line to align with label in desired placeWhy does a single feature's label not show?

Why can't I see bouncing of a switch on an oscilloscope?

What do you call something that goes against the spirit of the law, but is legal when interpreting the law to the letter?

If Manufacturer spice model and Datasheet give different values which should I use?

Why are 150k or 200k jobs considered good when there are 300k+ births a month?

Are tax years 2016 & 2017 back taxes deductible for tax year 2018?

Why has Russell's definition of numbers using equivalence classes been finally abandoned? ( If it has actually been abandoned).

Pronouncing Dictionary.com's W.O.D "vade mecum" in English

"which" command doesn't work / path of Safari?

Validation accuracy vs Testing accuracy

A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?

Why are only specific transaction types accepted into the mempool?

Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?

How to add power-LED to my small amplifier?

How can I hide my bitcoin transactions to protect anonymity from others?

How to re-create Edward Weson's Pepper No. 30?

What is the offset in a seaplane's hull?

Book about a traveler who helps planets in need

What do you call a Matrix-like slowdown and camera movement effect?

How is this relation reflexive?

Why is this code 6.5x slower with optimizations enabled?

Do any Labour MPs support no-deal?

Infinite past with a beginning?

Why Is Death Allowed In the Matrix?

A Journey Through Space and Time



Labeling polygons with the number of related table entries in QGIS


When labelling polygons, not all labels are displayed - QGIS 1.7.0Detecting densely labelled areas in ArcPy?Two different ways of labeling in QGIS LayouterUsing attribute data for legend labeling in QGIS?QGIS Labeling not workingLabel is appearing two times for some areas. How i can solve the problem, label should be shown one time for one areaIn MapBox Studio, how to create a centred label of a polygon created from shapefile?Label QGIS points layer with auto incrementing number count from 1QGIS 3 Line connecting point to label issue - can not get line to align with label in desired placeWhy does a single feature's label not show?






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








4















Using QGIS 3.6.1 I have a layer with areas and a table with entries related to the areas:



enter image description here



A relation is defined like this:



enter image description here



What I would like to achieve is to label the areas with the number of related table entries using relation_aggregate function as shown here:



enter image description here



relation_aggregate ('my_relation', 'count', 'text') || ' Table entries'


As can be seen in the screenshot (Output preview), the label expression delivers a valid result as expected (e.g. "4 Table Entries"), but labels are not shown in the map:



enter image description here



Another thing I tried using the aggregate function is the following:



enter image description here



with_variable('my_id', "id", aggregate('table', 'count', 'id', "flaeche_id" = @my_id)) || ' Table Entries'


Which gives a totally weird result depending on which area is shown in the current map extent, i.e.



1) Both areas labelled with "4 Table entries", but the lower has only one related table entry (see table above):



enter image description here



2) If the map extents only to the southernmost area, the label shows correctly "1 Table entries":



enter image description here



So all in all with my first approach I have no labels and with the second approach I have wrong labels.



I think I'm little stuck with the aggregate... functions in QGIS 3, am I using them the wrong way or are there any other approaches to the labeling I want to achieve?










share|improve this question
























  • did you try eval(relation_aggregate ('my_relation', 'count', 'text') || ' Table entries')?

    – PieterB
    Apr 4 at 10:09











  • just did so, same result either. no labels.

    – Jochen Schwarze
    Apr 4 at 10:19

















4















Using QGIS 3.6.1 I have a layer with areas and a table with entries related to the areas:



enter image description here



A relation is defined like this:



enter image description here



What I would like to achieve is to label the areas with the number of related table entries using relation_aggregate function as shown here:



enter image description here



relation_aggregate ('my_relation', 'count', 'text') || ' Table entries'


As can be seen in the screenshot (Output preview), the label expression delivers a valid result as expected (e.g. "4 Table Entries"), but labels are not shown in the map:



enter image description here



Another thing I tried using the aggregate function is the following:



enter image description here



with_variable('my_id', "id", aggregate('table', 'count', 'id', "flaeche_id" = @my_id)) || ' Table Entries'


Which gives a totally weird result depending on which area is shown in the current map extent, i.e.



1) Both areas labelled with "4 Table entries", but the lower has only one related table entry (see table above):



enter image description here



2) If the map extents only to the southernmost area, the label shows correctly "1 Table entries":



enter image description here



So all in all with my first approach I have no labels and with the second approach I have wrong labels.



I think I'm little stuck with the aggregate... functions in QGIS 3, am I using them the wrong way or are there any other approaches to the labeling I want to achieve?










share|improve this question
























  • did you try eval(relation_aggregate ('my_relation', 'count', 'text') || ' Table entries')?

    – PieterB
    Apr 4 at 10:09











  • just did so, same result either. no labels.

    – Jochen Schwarze
    Apr 4 at 10:19













4












4








4








Using QGIS 3.6.1 I have a layer with areas and a table with entries related to the areas:



enter image description here



A relation is defined like this:



enter image description here



What I would like to achieve is to label the areas with the number of related table entries using relation_aggregate function as shown here:



enter image description here



relation_aggregate ('my_relation', 'count', 'text') || ' Table entries'


As can be seen in the screenshot (Output preview), the label expression delivers a valid result as expected (e.g. "4 Table Entries"), but labels are not shown in the map:



enter image description here



Another thing I tried using the aggregate function is the following:



enter image description here



with_variable('my_id', "id", aggregate('table', 'count', 'id', "flaeche_id" = @my_id)) || ' Table Entries'


Which gives a totally weird result depending on which area is shown in the current map extent, i.e.



1) Both areas labelled with "4 Table entries", but the lower has only one related table entry (see table above):



enter image description here



2) If the map extents only to the southernmost area, the label shows correctly "1 Table entries":



enter image description here



So all in all with my first approach I have no labels and with the second approach I have wrong labels.



I think I'm little stuck with the aggregate... functions in QGIS 3, am I using them the wrong way or are there any other approaches to the labeling I want to achieve?










share|improve this question
















Using QGIS 3.6.1 I have a layer with areas and a table with entries related to the areas:



enter image description here



A relation is defined like this:



enter image description here



What I would like to achieve is to label the areas with the number of related table entries using relation_aggregate function as shown here:



enter image description here



relation_aggregate ('my_relation', 'count', 'text') || ' Table entries'


As can be seen in the screenshot (Output preview), the label expression delivers a valid result as expected (e.g. "4 Table Entries"), but labels are not shown in the map:



enter image description here



Another thing I tried using the aggregate function is the following:



enter image description here



with_variable('my_id', "id", aggregate('table', 'count', 'id', "flaeche_id" = @my_id)) || ' Table Entries'


Which gives a totally weird result depending on which area is shown in the current map extent, i.e.



1) Both areas labelled with "4 Table entries", but the lower has only one related table entry (see table above):



enter image description here



2) If the map extents only to the southernmost area, the label shows correctly "1 Table entries":



enter image description here



So all in all with my first approach I have no labels and with the second approach I have wrong labels.



I think I'm little stuck with the aggregate... functions in QGIS 3, am I using them the wrong way or are there any other approaches to the labeling I want to achieve?







labeling qgis-3 relates aggregation






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 4 at 8:01







Jochen Schwarze

















asked Apr 4 at 7:53









Jochen SchwarzeJochen Schwarze

6,63742058




6,63742058












  • did you try eval(relation_aggregate ('my_relation', 'count', 'text') || ' Table entries')?

    – PieterB
    Apr 4 at 10:09











  • just did so, same result either. no labels.

    – Jochen Schwarze
    Apr 4 at 10:19

















  • did you try eval(relation_aggregate ('my_relation', 'count', 'text') || ' Table entries')?

    – PieterB
    Apr 4 at 10:09











  • just did so, same result either. no labels.

    – Jochen Schwarze
    Apr 4 at 10:19
















did you try eval(relation_aggregate ('my_relation', 'count', 'text') || ' Table entries')?

– PieterB
Apr 4 at 10:09





did you try eval(relation_aggregate ('my_relation', 'count', 'text') || ' Table entries')?

– PieterB
Apr 4 at 10:09













just did so, same result either. no labels.

– Jochen Schwarze
Apr 4 at 10:19





just did so, same result either. no labels.

– Jochen Schwarze
Apr 4 at 10:19










1 Answer
1






active

oldest

votes


















2














you have to double quote (") your last argument:



relation_aggregate('my_relation', 'count', "text") || ' Table entries'


the description of relation_aggregate says:




relation_aggregate(relation,aggregate,expression[,concatenator])



[ ] marks optional components




So if you just want to use a fieldname as expresion, you have to refer to it as "my_attribute", which is also standard in other expressions.



Somehow, the fieldcalulator returns a result when using a single quote ('), bizar ...






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%2f317732%2flabeling-polygons-with-the-number-of-related-table-entries-in-qgis%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









    2














    you have to double quote (") your last argument:



    relation_aggregate('my_relation', 'count', "text") || ' Table entries'


    the description of relation_aggregate says:




    relation_aggregate(relation,aggregate,expression[,concatenator])



    [ ] marks optional components




    So if you just want to use a fieldname as expresion, you have to refer to it as "my_attribute", which is also standard in other expressions.



    Somehow, the fieldcalulator returns a result when using a single quote ('), bizar ...






    share|improve this answer





























      2














      you have to double quote (") your last argument:



      relation_aggregate('my_relation', 'count', "text") || ' Table entries'


      the description of relation_aggregate says:




      relation_aggregate(relation,aggregate,expression[,concatenator])



      [ ] marks optional components




      So if you just want to use a fieldname as expresion, you have to refer to it as "my_attribute", which is also standard in other expressions.



      Somehow, the fieldcalulator returns a result when using a single quote ('), bizar ...






      share|improve this answer



























        2












        2








        2







        you have to double quote (") your last argument:



        relation_aggregate('my_relation', 'count', "text") || ' Table entries'


        the description of relation_aggregate says:




        relation_aggregate(relation,aggregate,expression[,concatenator])



        [ ] marks optional components




        So if you just want to use a fieldname as expresion, you have to refer to it as "my_attribute", which is also standard in other expressions.



        Somehow, the fieldcalulator returns a result when using a single quote ('), bizar ...






        share|improve this answer















        you have to double quote (") your last argument:



        relation_aggregate('my_relation', 'count', "text") || ' Table entries'


        the description of relation_aggregate says:




        relation_aggregate(relation,aggregate,expression[,concatenator])



        [ ] marks optional components




        So if you just want to use a fieldname as expresion, you have to refer to it as "my_attribute", which is also standard in other expressions.



        Somehow, the fieldcalulator returns a result when using a single quote ('), bizar ...







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 4 at 12:40

























        answered Apr 4 at 10:49









        PieterBPieterB

        2,7701128




        2,7701128



























            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%2f317732%2flabeling-polygons-with-the-number-of-related-table-entries-in-qgis%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

            Bulk add to cart function issuecart vs. mini cart issue … rwd themeRedirect Add to cart button to cart pageAdd to cart issue - Magento 2.1The requested Payment Method is not available When creating an orderM2: reason add-to-cart might not function in production modeAdd to cart issue in some android devicesMagento 2 - custom price can not add to subtotal and grand total after add to cartAdd to cart codeIssue with my cart module on pdp and cart pages, just keeps spinningBulk price and quantity update using rest api

            БиармияSxpst500bh2ntaf! 3h2r