Ask a questionAsk a question
 

AnswerHow to edit XPath count function in SP Dataview

  • Friday, November 06, 2009 7:57 PMDavid Andrew Smith Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    <tr>
        <td class="ms-vb">Trip Count : <xsl:value-of select="count(/dsQueryResponse/Rows/Row)" /></td>
       </tr>
       <tr>
        <td class="ms-vb">Warning Count : <xsl:value-of select="count(/dsQueryResponse/Rows/Row )" /></td>
       </tr>

    Trip Count above counts the total number of forms entered by traveller - the xpath expression works like a charm...

    How do I edit the same expression to give a count of forms that have the 'warning' attribute = 'Yes'? (warning variable from dataview = Travel_x0020_Warning)

    For example, I tried the following with no luck:

     <tr>
        <td class="ms-vb">Warning Count : <xsl:value-of select="count(/dsQueryResponse/Rows/Row[@Travel_x0020_Warning='Yes'] )" /></td>
       </tr>

    Thank you in advance for any help,

    David

Answers

  • Monday, November 09, 2009 8:49 PMloya Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    I see. The column type is checkbox type. I am not too sure what are the value if checkbox type is used.

    My case was it was a dropdown choice. so the values were string type. When I used this: count(/dsQueryResponse/Rows [@Travel_x0020_Warning='Yes'] ), it worked fine. I could be because of column type..

All Replies

  • Friday, November 06, 2009 8:10 PMloya Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    When you try <xsl:value-of select="count(/dsQueryResponse/Rows/Row[@Travel_x0020_Warning='Yes'] )" />, what number do you get?

    I would try <xsl:value-of select="count(/dsQueryResponse/Rows [@Travel_x0020_Warning='Yes'] )" />

  • Friday, November 06, 2009 8:30 PMDavid Andrew Smith Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thank you so much for the quick response :)...

    Both expressions above return '0' even though there is at least one row ='Yes'. This warning column is a Yes/No checkbox. I also tried changing 'Yes' to 'True' and '1' but all return zero also.

    I have a feeling that I'm missing something simple but I can't figure it out, lol!
  • Monday, November 09, 2009 8:49 PMloya Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    I see. The column type is checkbox type. I am not too sure what are the value if checkbox type is used.

    My case was it was a dropdown choice. so the values were string type. When I used this: count(/dsQueryResponse/Rows [@Travel_x0020_Warning='Yes'] ), it worked fine. I could be because of column type..