{"id":2891,"date":"2011-11-30T11:30:58","date_gmt":"2011-11-30T03:30:58","guid":{"rendered":"http:\/\/www.sharepointboost.com\/blog\/?p=2891"},"modified":"2023-07-31T11:40:23","modified_gmt":"2023-07-31T03:40:23","slug":"how-to-use-c-to-read-sharepoint-kpi-list-value","status":"publish","type":"post","link":"https:\/\/www.boostsolutions.com\/blog\/how-to-use-c-to-read-sharepoint-kpi-list-value\/","title":{"rendered":"How to Use C# to read SharePoint KPI List Value"},"content":{"rendered":"<p>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#.<\/p>\n<p>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#.<\/p>\n<p>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.<\/p>\n<p><strong>Some description of KPIData properties.<\/strong><\/p>\n<p><a href=\"http:\/\/www.BoostSolutions.com\/blog\/wp-content\/uploads\/2011\/11\/KPI1.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-3020\" src=\"http:\/\/www.BoostSolutions.com\/blog\/wp-content\/uploads\/2011\/11\/KPI1.png\" alt=\"\" width=\"687\" height=\"238\" srcset=\"https:\/\/www.boostsolutions.com\/blog\/wp-content\/uploads\/2011\/11\/KPI1.png 687w, https:\/\/www.boostsolutions.com\/blog\/wp-content\/uploads\/2011\/11\/KPI1-300x103.png 300w\" sizes=\"(max-width: 687px) 100vw, 687px\" \/><\/a><\/p>\n<p><!--more--><strong>Now , if we get KPIConsts.KPIData we will get KPI values.<\/strong><\/p>\n<p><strong>If we use SharePoint 2010 we will use<\/strong><\/p>\n<p><strong> <\/strong><span style=\"color: #66cccc;\">Assembly<\/span> asm = System.Reflection.<span style=\"color: #66cccc;\">Assembly<\/span>.Load(<span style=\"color: #cc0066;\">&#8220;Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&#8221;<\/span>);<\/p>\n<p><strong>In SharePoint 2007 use<\/strong><\/p>\n<p><span style=\"color: #66cccc;\">Assembly<\/span> asm = System.Reflection.<span style=\"color: #66cccc;\">Assembly<\/span>.Load(<span style=\"color: #993366;\"><span style=\"color: #cc0066;\">&#8220;Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c<\/span>&#8220;<\/span>);<\/p>\n<p><strong>we have another way to load this dll which does not specifies version.<\/strong><\/p>\n<p><span style=\"color: #66cccc;\">Type<\/span> kpiDataType = <span style=\"color: #0000ff;\">typeof<\/span>(<span style=\"color: #66cccc;\">KPIConsts.KPIData<\/span>);<\/p>\n<p><span style=\"color: #66cccc;\">Assembly<\/span> asm = <span style=\"color: #66cccc;\">Assembly<\/span>.GetAssembly(kpiDataType);<\/p>\n<p><strong>When we get this assembly we can use reflect to get KPI list value.<\/strong><\/p>\n<p><strong>The first step is to get KPI Factory Type, this class is static.<\/strong><\/p>\n<p><span style=\"color: #66cccc;\">Type<\/span>kpiFactoryType=asm.GetType(<span style=\"color: #cc0066;\">&#8220;Microsoft.SharePoint.Portal.WebControls.KpiFactory&#8221;<\/span>);<\/p>\n<p><strong>The second step is to get KPI data, but this data object does not contain KPI values.<\/strong><\/p>\n<p><span style=\"color: #0000ff;\">object<\/span> kpi = kpiFactoryType.InvokeMember(&#8220;<span style=\"color: #cc0066;\">GetKpi<\/span>&#8220;, <span style=\"color: #66cccc;\">BindingFlags<\/span>.InvokeMethod | <span style=\"color: #66cccc;\">BindingFlags<\/span>.NonPublic | <span style=\"color: #66cccc;\">BindingFlags<\/span>.Public | <span style=\"color: #66cccc;\">BindingFlags<\/span>.Static, <span style=\"color: #0000ff;\">null<\/span>,<span style=\"color: #0000ff;\">null<\/span>, <span style=\"color: #0000ff;\">new object<\/span>[] { item });<\/p>\n<p>The third step is to get KPIData, this data is what we need.<\/p>\n<p><span style=\"color: #66cccc;\">Object <\/span>data = kpi.GetType().InvokeMember(&#8220;<span style=\"color: #cc0066;\">GetKpiData<\/span>&#8220;, <span style=\"color: #66cccc;\">BindingFlags<\/span>.InvokeMethod | <span style=\"color: #66cccc;\">BindingFlags<\/span>.Public | <span style=\"color: #66cccc;\">BindingFlags<\/span>.NonPublic |<span style=\"color: #66cccc;\"> BindingFlags<\/span>.Instance, <span style=\"color: #0000ff;\">null<\/span>, kpi, <span style=\"color: #0000ff;\">new object<\/span>[] { });<\/p>\n<p><span style=\"color: #66cccc;\">KPIConsts<\/span>.<span style=\"color: #66cccc;\">KPIData <\/span>kpidata= <span style=\"color: #0000ff;\">return<\/span> data <span style=\"color: #0000ff;\">as<\/span> <span style=\"color: #66cccc;\">KPIConsts<\/span>.<span style=\"color: #66cccc;\">KPIData<\/span><\/p>\n<p><strong>The last step is to use KPIData properties in your project.<\/strong><\/p>\n<p>Except this, KPI object has some filter features, with Indicator using data in SharePoint list content type.<\/p>\n<p>To specify the Indicator value: Section choice.<\/p>\n<p>Calculation using all list items in the view.<\/p>\n<p>If have some item setting like this, you can add filter feature using other code.<\/p>\n<p><a href=\"http:\/\/www.BoostSolutions.com\/blog\/wp-content\/uploads\/2011\/11\/1.How-to-Use-C-to-read-SharePoint-KPI-List-Value.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" loading=\"lazy\" class=\"alignleft size-full wp-image-3090\" title=\"1.How to Use C# to read SharePoint KPI List Value\" src=\"http:\/\/www.BoostSolutions.com\/blog\/wp-content\/uploads\/2011\/11\/1.How-to-Use-C-to-read-SharePoint-KPI-List-Value.png\" alt=\"\" width=\"662\" height=\"675\" srcset=\"https:\/\/www.boostsolutions.com\/blog\/wp-content\/uploads\/2011\/11\/1.How-to-Use-C-to-read-SharePoint-KPI-List-Value.png 662w, https:\/\/www.boostsolutions.com\/blog\/wp-content\/uploads\/2011\/11\/1.How-to-Use-C-to-read-SharePoint-KPI-List-Value-294x300.png 294w\" sizes=\"(max-width: 662px) 100vw, 662px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/www.BoostSolutions.com\/blog\/wp-content\/uploads\/2011\/11\/2.How-to-Use-C-to-read-SharePoint-KPI-List-Value.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" loading=\"lazy\" class=\"alignleft size-full wp-image-3091\" title=\"2.How to Use C# to read SharePoint KPI List Value\" src=\"http:\/\/www.BoostSolutions.com\/blog\/wp-content\/uploads\/2011\/11\/2.How-to-Use-C-to-read-SharePoint-KPI-List-Value.png\" alt=\"\" width=\"677\" height=\"748\" srcset=\"https:\/\/www.boostsolutions.com\/blog\/wp-content\/uploads\/2011\/11\/2.How-to-Use-C-to-read-SharePoint-KPI-List-Value.png 677w, https:\/\/www.boostsolutions.com\/blog\/wp-content\/uploads\/2011\/11\/2.How-to-Use-C-to-read-SharePoint-KPI-List-Value-271x300.png 271w\" sizes=\"(max-width: 677px) 100vw, 677px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>IFilterValues is a interface which has two properties :<\/p>\n<p>1. public string ParameterName : returns filter field name, this field name is the displayed name.<\/p>\n<p>2. public ReadOnlyCollection&lt;string&gt; ParameterValues : returns all filter conditions.<\/p>\n<p>you can implement filter interface like this.<\/p>\n<p><a href=\"http:\/\/www.BoostSolutions.com\/blog\/wp-content\/uploads\/2011\/11\/3.How-to-Use-C-to-read-SharePoint-KPI-List-Value.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" loading=\"lazy\" class=\"alignleft size-full wp-image-3092\" title=\"3.How to Use C# to read SharePoint KPI List Value\" src=\"http:\/\/www.BoostSolutions.com\/blog\/wp-content\/uploads\/2011\/11\/3.How-to-Use-C-to-read-SharePoint-KPI-List-Value.png\" alt=\"\" width=\"636\" height=\"545\" srcset=\"https:\/\/www.boostsolutions.com\/blog\/wp-content\/uploads\/2011\/11\/3.How-to-Use-C-to-read-SharePoint-KPI-List-Value.png 636w, https:\/\/www.boostsolutions.com\/blog\/wp-content\/uploads\/2011\/11\/3.How-to-Use-C-to-read-SharePoint-KPI-List-Value-300x257.png 300w\" sizes=\"(max-width: 636px) 100vw, 636px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":44,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[125],"tags":[270,268,269],"_links":{"self":[{"href":"https:\/\/www.boostsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2891"}],"collection":[{"href":"https:\/\/www.boostsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.boostsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.boostsolutions.com\/blog\/wp-json\/wp\/v2\/users\/44"}],"replies":[{"embeddable":true,"href":"https:\/\/www.boostsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=2891"}],"version-history":[{"count":12,"href":"https:\/\/www.boostsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2891\/revisions"}],"predecessor-version":[{"id":9273,"href":"https:\/\/www.boostsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2891\/revisions\/9273"}],"wp:attachment":[{"href":"https:\/\/www.boostsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=2891"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.boostsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=2891"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.boostsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=2891"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}