Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aggregate function with filter doesn't work in layout manager #45552

Closed
2 tasks done
katagen opened this issue Oct 18, 2021 · 4 comments
Closed
2 tasks done

Aggregate function with filter doesn't work in layout manager #45552

katagen opened this issue Oct 18, 2021 · 4 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Print Layouts Related to QGIS Print Layouts, Atlas or Reporting frameworks

Comments

@katagen
Copy link

katagen commented Oct 18, 2021

What is the bug or the crash?

I have a point layer named "Observation", with different attributes and one called "field_year" (date). My project also have a variable called @year.

In the layout, I have a A0 page (1189x841), but I want an extra space to put my attribute table (1cm for each row). So I'm trying to calculate the size with this formula, and it's worked fine:

841 + (10 * layer_property('Observation', 'feature_count'))

My problem is that my attribute table shows only the observations for the given year (@year), with this formula as a filter:
to_string(year("field_year")) LIKE @year

So to be able to count only the number of rows for a given year, I want to use the "aggregate" function, like this (single or double quotes for attributes doesn't change anything):

aggregate(
    layer:='Observation',
    aggregate:='count',
    expression:="field_year",
    filter:=to_string(year("field_year")) LIKE @year
  )

But it always says "No feature was found to evaluate the expression".
If I use the same expression to calculate a field in the attribute table, the function works (the pictures shows attributes in French, but it's the same).

1

2

Steps to reproduce the issue

  1. Open QGIS.
  2. Load a vector data, with one attribute to filter.
  3. Go to Layout manager, and choose for exemple A4.
  4. In the size of the paper, try to set the high with an expression.
  5. Use the aggregate expression to count the number of features ('count'), WITH a filter expression.

Versions

Version de QGIS
3.16.10-Hannover
Révision du code
e5b665e
Compilé avec Qt
5.15.2
Utilisant Qt
5.15.2
Compilé avec GDAL/OGR
3.3.1
Utilisé avec GDAL/OGR
3.3.1
Compilé avec GEOS
3.9.1-CAPI-1.14.2
Utilisé avec GEOS
3.9.1-CAPI-1.14.2
Compilé avec SQLite
3.35.2
Fonctionne avec SQLite
3.35.2
Version du client PostgreSQL
13.0
Version de SpatiaLite
5.0.1
Version de QWT
6.1.3
Version de QScintilla2
2.11.5
Compilé avec PROJ
8.1.0
Fonctionne avec PROJ
Rel. 8.1.0, July 1st, 2021
Version de l'OS
Windows 10 Version 2009
Extensions Python actives
AnotherDXF2Shape;
AppendFeaturesToLayer;
autoSaver;
CalculateGeometry;
catalogotf_plugin;
changeDataSource;
color_attribute;
DataPlotly;
DigitizingTools;
lizmap;
loadthemall;
LocatePoints;
lrs;
MapsPrinter;
mask;
menu_from_project;
Mergin;
profiletool;
qgis2web;
slyr_community;
SpreadsheetLayers;
swissgeodownloader;
swiss_locator;
TomBio;
VectorBender;
ViewshedAnalysis;
db_manager;
processing

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

  • I tried with a new QGIS profile

Additional context

The "aggregate" function shows no error in the layout manager, if we don't add a filter. But the value is always zero.

@katagen katagen added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Oct 18, 2021
@gioman gioman added the Print Layouts Related to QGIS Print Layouts, Atlas or Reporting frameworks label Oct 18, 2021
@elpaso
Copy link
Contributor

elpaso commented Feb 8, 2022

Can you please attach a test project to reproduce the issue?

@elpaso elpaso added the Feedback Waiting on the submitter for answers label Feb 8, 2022
@elpaso elpaso changed the title Aggregate fonction doesn't work in layout manager Aggregate function with filter doesn't work in layout manager Feb 8, 2022
@katagen
Copy link
Author

katagen commented Feb 10, 2022

The variable @year is written Année in this project. As you can see, I can't use the formula to define the height of my page in the print layout.
PL_Suivi d'efficacité.zip

@DelazJ
Copy link
Contributor

DelazJ commented Feb 10, 2022

Remind me somehow #42884 though in that case, the OK button was accessible

@gioman gioman removed the Feedback Waiting on the submitter for answers label Feb 10, 2022
@elpaso
Copy link
Contributor

elpaso commented Feb 11, 2022

Works for me.

immagine

@elpaso elpaso closed this as completed Feb 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Print Layouts Related to QGIS Print Layouts, Atlas or Reporting frameworks
Projects
None yet
Development

No branches or pull requests

4 participants