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 have a library with @Author, @status, and @fileleafref (document).

I have the following line in the dvt_1 template in my DVWP

<xsl:variable name="C_Draft" select="count($Rows[normalize-space(@Status)='Draft'])" />

This works, but I want to return only the count for items where @status is draft "and" where @Author = Field value of @Author (thus dynamic). So, for example, do a count where status=draft and author=john smith. How would I do this in a situation where there are a number of authors?

EDIT Here's what I've got based on your GetUsername template (thanks):

<xsl:variable name="AuthoredBy"  select="substring-after(substring-before(substring-after(@Author, 'ID='), '&lt;'), '&gt;')"/>
<xsl:variable name="C_Draft" select="count($Rows[normalize-space(@Status)='Draft' and @Author = $AuthoredBy])" />

This returns 0, though it should show 1 for author1. So I tried this, which also returns 0. It does parse and return the correct Username, which I checked.

<xsl:variable name="C_Draft" select="count($Rows[@Author = $AuthoredBy])" />

Then I tried this:

<xsl:variable name="C_Draft" select="count($Rows[normalize-space(@Status)='Draft' and $AuthoredBy = 'Author2Name'])" />

This gave me a value of 1, but it is Author 1 that has 1 item in draft status, not author 2.

Any suggestions?

share|improve this question
    
have you try domain\jsmith or whatever the domain id for the author? –  Mary Rivers Oct 14 '11 at 15:42

2 Answers 2

up vote 3 down vote accepted

You can add the additional filter clause inside the brackets with and. If both conditions are true, the row (item) will be included in the sum.

@Author is a Person or Group column, so you'll need to parse out the part of the HTML which represents the person that you need. See my XSL templates at the SPXSLT Codeplex Project (http://SPXSLT.codeplex.com).

share|improve this answer
    
Marc, I posted my reply but the sample code/results from your reply got added below the question. I seem to be running into trouble with counting using the person group column as a filter. Thanks for pointing me to your SP templates. Parsing string worked. –  Madstowe Oct 19 '11 at 17:08
    
This is now solved. I was using the GetUserName template from the series of templates that Marc has made available, when I should have been using GetUserID template. –  Madstowe Oct 20 '11 at 14:32
    
Can you mark the answer? :-) –  Marc D Anderson Oct 22 '11 at 11:42
    
Sorry Marc. New to the site and my other computer wasn't showing the check mark so I assume whether or not the check mark shows is cookie based. Thanks for your help! –  Madstowe Oct 23 '11 at 14:25

What you need to do is do a 'Group By' in XSLT so that the counts are grouped by Author. Although, not exactly the same thing, I believe the following solution could be modified to work for you: Grouping XML using XSLT

share|improve this answer

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.