A Key Performance Indicator (KPI) is a visual clue that communicates the amount of progress made towards a goal. This article explains how to read KPI values using C#.
Key Performance Indicators are valuable for teams, managers, and businesses to evaluate quickly the progress made regarding to measurable goals, but we cannot use common SharePoint object module to read kpi list value. If you cannot use MS API to read this information, if you want to access KPI list value you should use c#.
All SharePoint KPI List Code is contained in Microsoft.SharePoint.Portal.dll, and most core code about KPI list cannot be accessed using SharePoint API because they use internal keywords. Luckily, a KPIData class is public, we can access it and the KPI List Value contained in this class.
Some description of KPIData properties.
Now , if we get KPIConsts.KPIData we will get KPI values.
If we use SharePoint 2010 we will use
Assembly asm = System.Reflection.Assembly.Load(“Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”);
In SharePoint 2007 use
Assembly asm = System.Reflection.Assembly.Load(“Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c“);
we have another way to load this dll which does not specifies version.
Type kpiDataType = typeof(KPIConsts.KPIData);
Assembly asm = Assembly.GetAssembly(kpiDataType);
When we get this assembly we can use reflect to get KPI list value.
The first step is to get KPI Factory Type, this class is static.
TypekpiFactoryType=asm.GetType(“Microsoft.SharePoint.Portal.WebControls.KpiFactory”);
The second step is to get KPI data, but this data object does not contain KPI values.
object kpi = kpiFactoryType.InvokeMember(“GetKpi“, BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static, null,null, new object[] { item });
The third step is to get KPIData, this data is what we need.
Object data = kpi.GetType().InvokeMember(“GetKpiData“, BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, kpi, new object[] { });
KPIConsts.KPIData kpidata= return data as KPIConsts.KPIData
The last step is to use KPIData properties in your project.
Except this, KPI object has some filter features, with Indicator using data in SharePoint list content type.
To specify the Indicator value: Section choice.
Calculation using all list items in the view.
If have some item setting like this, you can add filter feature using other code.
IFilterValues is a interface which has two properties :
1. public string ParameterName : returns filter field name, this field name is the displayed name.
2. public ReadOnlyCollection<string> ParameterValues : returns all filter conditions.
you can implement filter interface like this.
Of course there are some unclear parameters that do various other things, I will update as soon as I figure out what they are but if all you want is read KPI values the explanation above is sufficient.