2

Currently I have a table of layout names, that are now linked to some layout template to pull the supplement nr, titel of the map and the sourc(for example AGIV, DOV, etc.)

This I have done by just adding some attribute table frames with the filter "Layout" = @layout_name. Now I want to take this one step further, in the actual table I also have the name of the viewport/theme of the map, normally this was used to keep a record of the theme of the map I should use.

So how do I build the expression that the name of the map theme gets pulled from a certain table (in this case the "QGIS Bijlagen Lijst) or rather from a certain layer without geometry?

Edit: here is the list of name and layer theme, note I have added a fifth variable called scale (schaal). Which is surprise surprise supposed to be the scale of the layout. The formula for the theme should theoretically being used for the scale as well.

enter image description here

8
  • What is wrong with using [% @layout_name %] in the print composer directly?
    – Erik
    Commented Sep 7, 2020 at 13:09
  • I am already using Layout_name as title for plan. The theme name and layout name is different. You have four vallue's Titel, Layout (this the layout_name for the filter), Bron And Theme Commented Sep 7, 2020 at 13:13
  • Ah, I see. You could "convert" the table into an expression which uses CASE WHENs to determine which map-theme name to use? Or is there a direct, unique connection between layout name and map theme name?
    – Erik
    Commented Sep 7, 2020 at 13:24
  • Yes kind of with a CASE WHEN. There is not a direct name connection with the theme name. Commented Sep 7, 2020 at 13:28
  • Can you provide an exhaustive list of combinations of @layout_name and theme name?
    – Erik
    Commented Sep 7, 2020 at 13:31

1 Answer 1

1

The following expression should give you the scale to you layout name.

aggregate('table layer', 'max', CASE WHEN @layout_name like "Lay-out" THEN "Schaal" END)

table layer needs to be replaced with the exact map layer name from the field calculator. You may use this expression as data defined override for your map element.

5
  • Nice solution but it seems only to work half the time for the scale for the other stuff like source and Titel it works for scale it does not. Commented Sep 8, 2020 at 7:46
  • "It doesn't work" as in "there is no return" or "the scale doesn't adjust"?
    – Erik
    Commented Sep 8, 2020 at 7:51
  • The scale does not adjust, it just go to random number 602,97...where it gets the number from is unclear. Because the number does not exist in the table. Commented Sep 8, 2020 at 8:07
  • Which field type is your schaal field? Integer?
    – Erik
    Commented Sep 8, 2020 at 8:13
  • It is in double. Commented Sep 9, 2020 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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