4

I want to highlight parts of a map based on the page number in an atlas. Ideally I'd use the expression builder in the layer style menu to set the Column to equal the atlas page number.

My expression is as follows

@atlas_pagename  || '_1' 

The page number is "1007" and the column is "1007_1" hence the need to add the _1 at the end. The next column is 1008_1 for example.

The expression successfully outputs 1007_1, but the expression builder doesn't recognise this as the name of a column.

Is there any way to make the expression builder not just output "1007_1" as a string, but to select the column "1007_1"?

I am trying to do this automatically with an expression so that when the atlas moves onto page 1008 the layer will move onto column 1008_1 and so on.

  • 1
    can you try something like attribute($atlas_feature, @atlas_pagename || '_1' ) ..? – Steven Kay Dec 13 '17 at 20:07
2

I think eval() is what you're looking for, i.e.:

eval('"'||@atlas_pagename||'_1'||'"')

The string in the brackets would be "1008_1", which should be evaluated as the attribute value in column 1008_1.

  • That worked perfectly! Thank you kindly! – Edward Hampson Dec 15 '17 at 11:09
  • My pleasure. The greatest way to say thank you is accepting an answer... ;-) – Jochen Schwarze Dec 15 '17 at 11:12
  • 1
    Ed - thanks for sharing, and Jochen thanks for providing the solution. I thought it would be useful to blog the method with examples and I've also shared a project file for people to play around with: statsmapsnpix.com/2019/01/qgis-atlas-by-field.html – Alasdair Rae Jan 2 at 8:25
0

You may add the column/field name from the Fields and Values option:

enter image description here

@atlas_pagename  || '_' || "columnFieldName"
  • Thank you, but I should have clarified that I want it to move along to the next column with the next atlas page. So when I move the atlas to Page Name 1008 or 1009, the layer moves along with it to Column 1008_1 or 1009_1. If I just select from the list as you suggest, it'll stay stuck on 1007. – Edward Hampson Dec 13 '17 at 13:58

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.