Anzeige "NAN" stattdessen Prozentsatz
-
10-12-2019 - |
Frage
Ich verwende SharePoint 2007 und entwickeln Sie eine benutzerdefinierte Ansicht mithilfe von SharePoint Designer 2007.
Ich habe eine Spalte einer Tabelle, die Zahlen als Prozentsatz anzeigen soll.Minimun-Wert beträgt 0, maximal 100.
In SP Designer verwende ich den vorgeschlagenen Code: generasacodicetagpre.
, aber es sei denn, ich füge eine Nummer wie 0 oder 100 ein, sehe ich immer "Nan".Es ist kein Standardwert eingestellt.
warum?
Lösung
You could capture the formatted number first and then check for a NaN value.
<xsl:variable name="myValue" select="format-number(@Probabilit_x00e0_, "###0,%;-###0,%", "lcid1040")" />
<xsl:choose>
<xsl:when test="string(number($myValue))='NaN'">0</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$myValue" />
</xsl:otherwise>
</xsl:choose>
This will switch out NaN for a zero.
Andere Tipps
When using "format-number", it expects a period separator for decimals. With the percentage field (LCID 1036 for french), the decimals separator is a comma.
I had to translate the comma to get it working correctly. I haven't checked if it is the same thing for 1033 or 1040 in this case.
format-number(string(translate(@PercentField,',','.')), '#,##0%;-#')