cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAPUI5: Wrong Deviation Calculation for KPI/DataPoint

tobias_grimm_ksg
Explorer
0 Kudos
695

I have an SAPUI5 application that is based on an FIORI Elements Overview Page template.
One of my cards on the OVP shows an KPI header with the following values:

  • KPI Value: Average Delivery Delay (in days) for the past 90 days
  • Target Value: Average Delivery Delay (in days) for the past 365 days
  • Automatically calculated deviation of the values  in %

We recently upgraded our system from S/4 2020 SP3 to S/4 2023 SP1. This included updating SAPUI5 libraries from 1.84.6 to 1.120.0. After the upgrade, the deviation calculation shows a wrong value. Before it worked as expected.

tobias_grimm_ksg_0-1734095637564.png

                
<Annotation Term="UI.DataPoint" Qualifier="DataPointDurchschnittLieferverzug">
	<Record Type="UI.DataPointType">
		<PropertyValue Property="Title" String="{@i18n>datapoint_title_durchschnitt_lieferverzug}" />
		<PropertyValue Property="Description" String="{@i18n>datapoint_title_durchschnitt_lieferverzug}" />
		<PropertyValue Property="Value" Path="AvgDelivToCmtdDelivDelayInDays" />
		<PropertyValue Property="CriticalityCalculation">
			<Record Type="UI.CriticalityCalculationType">
				<PropertyValue Property="ImprovementDirection" EnumMember="UI.ImprovementDirectionType/Minimize" />
				<PropertyValue Property="ToleranceRangeHighValue" Decimal="3" />
				<PropertyValue Property="DeviationRangeHighValue" Decimal="5" />
			</Record>
		</PropertyValue>
		<PropertyValue Property="TrendCalculation">
			<Record Type="UI.TrendCalculationType">
				<PropertyValue Property="ReferenceValue" Path="AvgDlvToCmtdDlvDelayPast365Day" />
				<PropertyValue Property="UpDifference" Decimal="1" />
				<PropertyValue Property="StrongUpDifference" Decimal="2" />
				<PropertyValue Property="DownDifference" Decimal="-1" />
				<PropertyValue Property="StrongDownDifference" Decimal="-2" />
			</Record>
		</PropertyValue>
		<PropertyValue Property="ValueFormat">
			<Record Type="UI.NumberFormat">
				<PropertyValue Property="NumberOfFractionalDigits" Int="1" />
			</Record>
		</PropertyValue>
	</Record>
</Annotation>

 

Accepted Solutions (1)

Accepted Solutions (1)

tobias_grimm_ksg
Explorer
0 Kudos

After discussing the issue with one of the developers of the framework, a fix was released in the latest patch level 28 (SAPUI5 version 1.120.28). The deviation calculation now behaves as expected again.

See this note to update to a newer patch level: https://me.sap.com/notes/3155948 

Answers (1)

Answers (1)

tobias_grimm_ksg
Explorer
0 Kudos

I guess I found the problem. The calculation of the deviation happens in the Frontend in sap.ovp.cards.Annotation-Helper.js. The following line was added in this function: 

function returnPercentageChange(iKpiValue, iTargetValue) {
   //...
   if (typeof iKpiValue == "string") {
      iKpiValue = NumberFormat.getIntegerInstance().parse(iKpiValue);
   }
   //...
}

 Since the KPI and Target values are retreived from the backend, they are read from the JSON response and will always be of type "string". Regardless of the actual type of the KPI, this code will always convert it to an integer. This causes two problems: 

  1. Fractional digits will be lost
  2. With german language settings, values like "65.123" will be converted to 65123 instead of 65.123

The combination of these two problems will cause the weird deviation values. 
I do not know why this line was added by SAP and why an Integer Conversion is used. Unlike the KPI value, the Target value is just converted to decimal using an implicit conversion...