Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I've written a web part that generates several KPIs based off a list given: - List and column names placed in custom configuration values - Parameters at run time

Each KPI is composed from a set of list rows dependent on the KPI and parameters. I.e., KPI 1 can be calculated from rows 1, 2 and 3 while KPI 2 can be calculated from rows 2, 4 and 6.

I want to be able to click on one of the KPI's and filter the list by the ID's that were used to calculate the KPI. The only solution I've found is to create a CAML statement with a List View Web Part but some KPI's will have up to a 1,000 records making the generated CAML statements pretty huge.

Ex. CAML with 3 records

<query>
<where>
<or>
<or>
<eq>
<fieldref name="ID">
<value type="Counter">1</value>
</fieldref>
</eq>
<eq>
<fieldref name="ID">
<value type="Counter">2</value>
</fieldref>
</eq>
</or>
<eq>
<fieldref name="ID">
<value type="Counter">3</value>
</fieldref>
</eq>
</or>
</where>
</query>

QUESTION

Is there a more efficient way to do this. I simply want to get all the rows that made up each KPI. Preferably using the List View Web Part so the user can further filter and sort as they wish.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I'd add a choice field to the list indication which KPIs it was part of (allowing multiple selections) and the checks for that choice field in the query (Eq works as long as value is one of the selected choices)

But if your only option is to query based on the IDs then using the <In> element is your best option like:

<Query> 
 <Where> 
  <In> 
   <fieldref name="ID"> 
   <Values>
    <Value type="Counter">1</Value> 
    <Value type="Counter">2</Value> 
    <Value type="Counter">3</Value> 
   </Values>
  </In>
 </Where> 
</Query> 
share|improve this answer
    
Thanks for this but I don't know what KPI the row will be in until run time. Its dependent on attribute values like status and the date an action happened combined with business logic that's not captured in the list. –  RWL01 Mar 23 '12 at 13:14
    
Added option based on that info to my answer –  Per Jakobsen Mar 23 '12 at 14:18
    
That's exactly what I was looking for, thanks. –  RWL01 Mar 23 '12 at 15:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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