There are times when I want to show a distinct dashboard style rollup of items in a list which match certain conditions. There isn’t a lot of documentation online on XPath expressions for SharePoint Data View webparts. Here is sample code to calculate the count of rows in a list. Be careful to choose the right column to count so that you are guaranteed to get the total you expect.
I have included styling as an example because, why wouldn’t we style the results?
<style type=”text/css”>
.DVRow {
background-color:blue;
font:normal normal bold 20px Calibri;
text-align:center;
color:white;
}
<td class=”DVRow”>
<asp:Label runat=”server” id=”ff1{$Pos}” text=”{count(/dsQueryResponse/Rows/Row/@Title)}” __designer:bind=”{ddwrt:DataBind('u', concat('ff1',$Pos), 'Text','','ID',ddwrt:EscapeDelims(string(@ID)),'count(/dsQueryResponse/Rows/Row/@Title')}” />
Pay close attention to the XPath formula: count(<a>/dsQueryResponse/Rows/Row/@Ti…