# Group by more than two columns: Calculate lowest average

• ### 질문

• Hi,

I have a list in Sharepoint 2007, which I grouped by 3 columns. So far so good, no issues I displayed an average of some values, but now I want to try to calculate the lowest average of a subgroup. Let me try to explain the situation:

I want to show in A: Titulo 1 the lowest value "Cumplimiento" of its descendants in this case there are:

Titulo 1- Subtitulo 1 Cumplimiento: 66.57%

Titulo 1- Subtitulo 2 Cumplimiento: 50.00%

Titulo 1- Subtitulo 3 Cumplimiento: 0.00%  (I want to display this one in the header of its parent which is A: Titulo 1)

I have tried this code in xpath.

`ddwrt:Min(sum(\$nodeset/@Cumplimiento) div count(\$nodeset))`

But I guess that if that would have worked the value would be wrong. I read something about descendant, siblings, etc.

The code should be like Min(B//Cumplimiento) but I cant figure out how to put that in xpath.

• 편집됨 2012년 5월 23일 수요일 오후 9:50 more details
2012년 5월 23일 수요일 오후 7:50

### 답변

• Ok I did some attemps of xpath and I think I understand a bit more.

I can display certain value using the respective filter, this was an example

`sum(\$nodeset[@B='Subtitulo 1']/@Cumplimiento) div count(\$nodeset[@B='Subtitulo 1'])`

So the solution would be something like this

```A= sum(\$nodeset[@A="Titulo 1" and @B='Subtitulo 1']/@Cumplimiento) div count(\$nodeset[@A="Titulo 1" and @B='Subtitulo 1'])

B= sum(\$nodeset[@A="Titulo 1" and @B='Subtitulo 2']/@Cumplimiento) div count(\$nodeset[@A="Titulo 1" and @B='Subtitulo 2'])

C= sum(\$nodeset[@A="Titulo 1" and @B='Subtitulo 3']/@Cumplimiento) div count(\$nodeset[@A="Titulo 1" and @B='Subtitulo 3'])

if (A<B)
{
if(A<C){
return A;
}else{
return C;
}
}else if (B<C){
return B;
}else{
return C;
}
```

Of course using some filters to hide this value in other headers but the one Im insterested to display it.

So still figuring out how to store that in variables....and do the the whole thing...

• 답변으로 표시됨 2012년 5월 31일 목요일 오전 6:24
2012년 5월 29일 화요일 오후 9:18

### 모든 응답

• Hi,

I'm trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

Thanks & Regards,
Emir

Emir Liu

TechNet Community Support

2012년 5월 25일 금요일 오후 1:12

The solution involve the use a arrays, I think that maybe using javascript I would be able to capture all the values then take the lowest one....anyway still figuring out how to do all that stuff.

2012년 5월 25일 금요일 오후 8:06
• Ok I did some attemps of xpath and I think I understand a bit more.

I can display certain value using the respective filter, this was an example

`sum(\$nodeset[@B='Subtitulo 1']/@Cumplimiento) div count(\$nodeset[@B='Subtitulo 1'])`

So the solution would be something like this

```A= sum(\$nodeset[@A="Titulo 1" and @B='Subtitulo 1']/@Cumplimiento) div count(\$nodeset[@A="Titulo 1" and @B='Subtitulo 1'])

B= sum(\$nodeset[@A="Titulo 1" and @B='Subtitulo 2']/@Cumplimiento) div count(\$nodeset[@A="Titulo 1" and @B='Subtitulo 2'])

C= sum(\$nodeset[@A="Titulo 1" and @B='Subtitulo 3']/@Cumplimiento) div count(\$nodeset[@A="Titulo 1" and @B='Subtitulo 3'])

if (A<B)
{
if(A<C){
return A;
}else{
return C;
}
}else if (B<C){
return B;
}else{
return C;
}
```

Of course using some filters to hide this value in other headers but the one Im insterested to display it.

So still figuring out how to store that in variables....and do the the whole thing...

• 답변으로 표시됨 2012년 5월 31일 목요일 오전 6:24
2012년 5월 29일 화요일 오후 9:18