SharePoint 2010 XSLT treating calculated column number as string which breaks ddwrt:Max
-
09-12-2020 - |
Question
I have a calculated column that is a number field. It basically adds to other number fields. When I look at the item through the website I see the format as "1,050" (with the comma).
In a DVWP using XSLT when I try to find the max value using 'ddwrt:Max(...)' it does not find the true max because it seems to be treating the values as strings where 900 is greater than 1000.
Here is a snippet of the dsQueryResponse
and my XSLT.
The dsQueryResponse
:
<dsQueryResponse>
<Rows>
<Row nCcTileRightEdge="125" ></Row>
<Row nCcTileRightEdge="225" ></Row>
<Row nCcTileRightEdge="325" ></Row>
<Row nCcTileRightEdge="425" ></Row>
<Row nCcTileRightEdge="525" ></Row>
<Row nCcTileRightEdge="625" ></Row>
<Row nCcTileRightEdge="725" ></Row>
<Row nCcTileRightEdge="825" ></Row>
<Row nCcTileRightEdge="925" ></Row>
<Row nCcTileRightEdge="1,025" ></Row>
</Rows>
</dsQueryResponse>
The XSLT in question:
<xsl:variable name="maxRightEdge" select="ddwrt:Max(/dsQueryResponse/Rows/Row/@nCcTileRightEdge)" />
And this is returning 925.
How can I get the true max?
Solution
You should be able to change your variable definition to convert the string to a number first:
<xsl:variable name="maxRightEdge" select="ddwrt:Max(number(/dsQueryResponse/Rows/Row/@nCcTileRightEdge))" />
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange