[Qgis-user] How to change what fields QGIS layout text tool reads?

Andreas Neumann a.neumann at carto.net
Wed Jun 26 02:35:07 PDT 2019


Hi Ville, 

Good that you got it working. 

Yes, this is the correct way to do it. You need to nest these functions.
After a lot of nesting, the expressions get harder to read. But you can
also write the expression in multiple lines with indentations. That
often makes it easier to read. 

Note that for providing the layer, you can either provide the internal
layer id (often quite long and hard to read) or the human readable layer
name - as long as the latter is unique in the project. 

Greetings, 

Andreas 

On 2019-06-26 11:16, Ville Koivisto wrote:

>> 

> HI AGAIN, 
> 
> Yes, there's a relation, both spatial and via attributes. I got it working with the syntax below: 
> 
> concat('The value is: ',(attribute(get_feature('layer name','Field that matches atlas page', @atlas_pagename),'Field for value'))) 
> 
> Thank you again, this was very helpful. I'll try to see if there's already a question related to this in stackexchange and if not, create one. 
> 
> BEST REGARDS, 
> 
> Ville Koivisto 
> 
> FROM: Andreas Neumann <a.neumann at carto.net> 
> SENT: Wednesday, June 26, 2019 10:45 AM
> TO: Ville Koivisto <ville.koivisto at kuntotekniikka.fi>
> CC: qgis-user at lists.osgeo.org
> SUBJECT: Re: [Qgis-user] How to change what fields QGIS layout text tool reads? 
> 
> Hi, 
> 
> I assume there is some kind of relation with common IDs or spatial relations between the coverage layer and the two other layers? 
> 
> If yes, any of the three methods I proposed should work fine. 
> 
> The text tool can only work with the coverage layer in Atlas context. All other layers will need to be retrieved through other methods, like the ones I described. 
> 
> Have a look at the examples (help) of the the get_feature() and get_feature_by_id() functions. They should help you get going. 
> 
> If not, then share with us the expression you tried. 
> 
> Andreas 
> 
> On 2019-06-26 09:33, Ville Koivisto wrote: 
> 
> Hi, 
> 
> Thank you very much for your prompt answer. I have an atlas in the making that has at least three different layers in it, one naturally being the coverage layer. I have several text boxes in the atlas which are supposed to retrieve useful info from one of the layers. Syntaxes differ, simpler ones being for example: 
> 
> concat('The value is', "Field") 
> 
> ...and I've been unable to fetch that "field" successfully. I assume that get_feature() / get_feature_by_id() and attribute() will get me further in this. By what logic the text tool chooses a layer from which to initially read fields (i.e. values user can check and use from drop down-menu _fields and values_)? 
> 
> Best regards, 
> 
> Ville Koivisto 
> 
> FROM: Andreas Neumann <a.neumann at carto.net> 
> SENT: Wednesday, June 26, 2019 10:21 AM
> TO: Ville Koivisto <ville.koivisto at kuntotekniikka.fi>
> CC: qgis-user at lists.osgeo.org
> SUBJECT: Re: [Qgis-user] How to change what fields QGIS layout text tool reads? 
> 
> Hi, 
> 
> What expression did you use? 
> 
> Here are some ideas what you could do: 
> 
> * get_feature() / get_feature_by_id() and attribute() - here you need some logic how to retrieve the related feature from the other layer
> * relation_aggregate() - allows you to have more than one match in the other layer and create aggregates
> * joins on layer properties - for 1:1 joins - needs to be done on layer properties
> 
> If you clarify more specifically what you want to do, we can more easily help. 
> 
> Also, if you have your expressions to share that you tried, it would help. 
> 
> Greetings, 
> 
> Andreas 
> 
> On 2019-06-26 09:06, Ville Koivisto wrote: 
> 
> HI LIST, 
> 
> I'm trying to add several texts to my layout and configure their contents by an expression. The problem is that the fields that expression dialog offers me under _fields and values _are from one certain layer and I need them from another one. I'm struggling to find a way to fetch fields from two other layers participating in the layout. 
> 
> If I try to use their fields in an expression I get: 
> 
> _Eval error: Column "Field" not found_ 
> 
> _ _ 
> 
> How to solve this? Thank you for your attention. 
> 
> BEST REGARDS, 
> 
> Ville Koivisto 
> 
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user [1]
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user [1]

 

Links:
------
[1] https://lists.osgeo.org/mailman/listinfo/qgis-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20190626/0f5b841b/attachment-0001.html>


More information about the Qgis-user mailing list