1

I have a calculated column that produces values from 0 to 20. While filtering the query for items greater or equal to 16 I still get all the values. The result of the Calculated column is a number (and not a text).

The query does successfully the filtering on another parameter (open, close).

The 2 parameters are correlated by AND (must be open and must be above 16).

Why it is not working?

  • Try exporting the CQWP and have a look the CAML query. If needed try tweaking the query and re import the webpart to the page – HarryB Nov 4 '16 at 10:40
  • How do I look at the CAML query? – susan Nov 4 '16 at 11:02
  • You can find your query filters in the exported xml with property names like: FilterField1. There is a QueryOverride property where you specify your own CAML. Some guidance here: blog.riccardocelesti.it/…. Also have you tried setting filter to greater than 15 rather than greater than or equal to 16 – HarryB Nov 4 '16 at 11:21
  • I have found the property (<property name="FilterField2" type="string">Severity</property>), how should I modify it? I have also tried with greater than but it behaves the same – susan Nov 4 '16 at 12:40
  • Have a look at my answer – HarryB Nov 4 '16 at 15:13
0

I have tested this and it works for me: Replace the QueryOverride property in the exported webpart as below (updated column names according to your list columns) and re import the webpart.

Rating is a calculated column in the query below with an output of type number. Status is a Choice field (dropdown)

 <property name="QueryOverride" type="string" >
              <![CDATA[
            <Where>
           <And>
            <Gt>
               <FieldRef Name='Rating' />
               <Value Type='Number'>1</Value>
            </Gt>
            <Eq>
               <FieldRef Name='Status' />
               <Value Type='Choice'>Close</Value>
            </Eq>
         </And>
         </Where>]]>
            </property>
  • Instead of rating I need to put my field name, right? and the status field does work from the query interface, am I forced to put it in the code or I can only put in the code the severity field? The number '1' is my number 16? or do I have to leave 1? – susan Nov 4 '16 at 15:19
  • You need to add both fields to the query. Replace 'Rating' field with your calculated field name and replace "Status" field with your choice field name. Replace number 1 with 15 – HarryB Nov 4 '16 at 15:24
  • Did this not work for you? – HarryB Nov 8 '16 at 15:45
  • for now I did a workflow that was replicating the total, I am going to try your other method tomorrow. I would still like to know why the query fails to recognize the value as number, I have seen in some forums people doing it fine with SP 2013 – susan Nov 8 '16 at 15:50
  • I think the query fails because the CQWP seems to configure the calculated field value as string and the only way to correct that is by overriding the default query by specifying your own CAML which works as expected. – HarryB Nov 8 '16 at 15:54

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.