2

I have a data file that contains current meter data for multiple days.

I am trying to use the Processing Modeller to extract a single days worth of data for further manipulation, using the extract by expression algorithm.

My input data layer has the date in it, with the format dd/mm/yy (i.e 01/12/19) enter image description here

I've tested my selection expression using Select by expression in QGIS as per below, which correctly selects 1 days worth of data.enter image description here

Building my model, I select the input later using a vector feature parameter definition. I then used String parameter definition to input the required date '25/12/19' and the date field "%Date"

enter image description hereenter image description here

I entered the below expression into the Processing Modeller to match the select by expression that I tested ealier. enter image description here

When I run the model, nothing is extracted to the result layer.

I'm sure it's probably a syntax problem, but cant figure it out.

2

I suspect its checking the literal value of the DateField Input against the literal value of the EnterDate input. In other words, its not extracting the value of the field named by the value of DateField. This looks like too many levels of indirection.

You probably need to use the attribute function to get the value of an attribute in a layer by a variable holding the name of the field. After a few tests I've got this to work:

 attribute(@datefield) = @enterdate

BUT you don't put the field name in quotes in the Input - just %Date, not "%Date" as you had. (Note I did everything in lowercase but that's not totally necessary)

To test it, I used the Field Calculator algorithm to create a new layer so I could see what the expression engine was computing for each part of the expression. After about 50 iterations of various attempts I think I've got it...

| improve this answer | |
  • Hi Spacedman You were correct. When i tried your suggestion, I got the data output that I wanted. Thank you for your time in helping me get this sorted. – Chris Bass Jan 5 at 5:52
  • @Chris Bass, Hello, if the answer solved your question, be sure to mark it as accepted. – Herbert Santos Jan 6 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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