Create Scorecards and Dashboards Programmatically in PerformancePoint

Hi All, I managed to create a Dashboard and a Scorecard programmatically, I failed to find any resources, articles or anything online talking about this subject.
That’s why I decided to share it online with you!

Here is the web project I created while I was investigating The PerformancePoint API ..

Firstly, Add a reference to :\Microsoft Office PerformancePoint Server\3.0\Monitoring\Assemblies\Microsoft.PerformancePoint.Scorecards.Common.dll
using Microsoft.PerformancePoint.Scorecards;
using System.Net;

public partial class _Default : System.Web.UI.Page
{
private Scorecard AScoreCard_wows;
private PmService Publisher;

protected override void OnInit(EventArgs e)
{
base.OnInit(e);
Publisher = (PmService)PmService.CreateInstance(“http://localhost:40000/webservice/pmservice.asmx”);
Publisher.Credentials = CredentialCache.DefaultNetworkCredentials;
}
protected void Page_Load(object sender, EventArgs e)
{
//CreateScoreCard();
}
protected void CreateScoreCard()
{
Guid AGuid;
// create a new scorecard instance
AScoreCard_wows = Scorecard.CreateNew();
// Setting the name property;
BpmPropertyText NameProperty = new BpmPropertyText();
NameProperty.Text = “The ScoreCard”;
AScoreCard_wows.Name = NameProperty;
AScoreCard_wows.Description.Text = “This Scorecard was created by code”;
// Setting the owner property
AScoreCard_wows.Owner.Login = @”Server\Administrator”;
// Configuring the scorecard view
ConfiguredView ACofiguredView = new ConfiguredView();
GridViewDefinition ParentChildDefinition = new GridViewDefinition();
GridHeaderItem ParentX = new GridHeaderItem();
AGuid = Guid.NewGuid();
ParentX.Guid = AGuid;
ParentX.DefinitionGuid = AGuid;
ParentX.DisplayText = “ParentX”;
ParentX.DimensionName = “Scorecard__”;
ParentX.DimensionValue = “cd30315e-bd40-4977-b21b-cbb47cc83494”; // Guid of KPI
ParentX.HeaderType = ScorecardNodeTypes.Kpi;
ParentX.Depth = 1;
ParentChildDefinition.RootRowHeader.Children.Add(ParentX);
GridHeaderItem ChildX = new GridHeaderItem();
AGuid = Guid.NewGuid();
ChildX.Guid = AGuid;
ChildX.DefinitionGuid = AGuid;
ChildX.DisplayText = “ChildX”;
ChildX.DimensionName = “Scorecard__”;
ChildX.DimensionValue = “e9ec1e6b-8c7e-4f7d-b87d-28cad4b29d7f”; // Guid of KPI
ChildX.LinkedKpiId = new Guid(“e9ec1e6b-8c7e-4f7d-b87d-28cad4b29d7f”);
ChildX.HeaderType = ScorecardNodeTypes.Kpi;
ChildX.Depth = 2;
ParentX.Children.Add(ChildX);
GridHeaderItem ChildY = new GridHeaderItem();
AGuid = Guid.NewGuid();
ChildY.Guid = AGuid;
ChildY.DefinitionGuid = AGuid;
ChildY.DisplayText = “ChildY”;
ChildY.DimensionName = “Scorecard__”;
ChildY.DimensionValue = “8878d533-b7b7-40f7-8772-4da81c54c85b”; // Guid of KPI
ChildY.LinkedKpiId = new Guid(“8878d533-b7b7-40f7-8772-4da81c54c85b”);
ChildY.HeaderType = ScorecardNodeTypes.Kpi;
ChildY.Depth = 2;
ParentX.Children.Add(ChildY);
GridHeaderItem ActualColumn = new GridHeaderItem();
AGuid = Guid.NewGuid();
ActualColumn.Guid = AGuid;
ActualColumn.DefinitionGuid = AGuid;
ActualColumn.DisplayText = “Actual”;
ActualColumn.DimensionName = “Scorecard_Measures__”;
ActualColumn.DimensionValue = “Actual”; // Guid of KPI
ActualColumn.HeaderType = ScorecardNodeTypes.KpiActual;
ActualColumn.Depth = 1;
GridTargetSettings ActualColumnTargetSettings = new GridTargetSettings();
ActualColumnTargetSettings.ShowImage = true;
ActualColumnTargetSettings.ShowScore = true;
ActualColumnTargetSettings.RollupType = RollupTypes.AverageWeighted;
ActualColumnTargetSettings.ScoreType = ScoreTypes.Normalized;
ActualColumn.TargetSettings = ActualColumnTargetSettings;
ParentChildDefinition.RootColumnHeader.Children.Add(ActualColumn);
GridHeaderItem TargetColumn = new GridHeaderItem();
AGuid = Guid.NewGuid();
TargetColumn.Guid = AGuid;
TargetColumn.DefinitionGuid = AGuid;
TargetColumn.DisplayText = “Target”;
TargetColumn.DimensionName = “Scorecard_Measures__”;
TargetColumn.DimensionValue = “Target”; // Guid of KPI
TargetColumn.HeaderType = ScorecardNodeTypes.KpiTarget;
TargetColumn.Depth = 1;
GridTargetSettings TargetColumnTargetSettings = new GridTargetSettings();
TargetColumnTargetSettings.ShowImage = true;
TargetColumnTargetSettings.ShowScore = true;
TargetColumnTargetSettings.RollupType = RollupTypes.AverageWeighted;
TargetColumnTargetSettings.ScoreType = ScoreTypes.Raw;
TargetColumn.TargetSettings = TargetColumnTargetSettings;
ParentChildDefinition.RootColumnHeader.Children.Add(TargetColumn);
ACofiguredView.GridViewDefinition = ParentChildDefinition;
AScoreCard_wows.ConfiguredViews.Add(ACofiguredView);
// Publishing the ScoreCard
Publisher.CreateScorecard(AScoreCard_wows);
}
protected void CreateDashBoard()
{
//Create An Instance
ADashboard_wows = Dashboard.CreateNew();
// Setting the Name
ADashboard_wows.Name.Text = “Ayman’s Dashboard__”;
//Setting the owner
ADashboard_wows.Owner.Login = @”Server\Administrator”;
//Adding A Page
// Creating a Page
DashboardElementContainer APage = new DashboardElementContainer();
APage.Guid = Guid.NewGuid();
APage.Name.Text = “Ayman’s Page__”;
APage.Owner.Login = @”Server\Administrator”;
// Creating A Zone
DashboardElementContainer AZone = new DashboardElementContainer();
AZone.Guid = Guid.NewGuid();
AZone.Name.Text = “Ayman’s Zone__”;
AZone.Owner.Login = @”Server\Administrator”;
// Creating a dashboard Item ( scorecard )
DashboardItem Item = new DashboardItem();
Item.Guid = Guid.NewGuid();
Item.UnderlyingElementId = AScoreCard_wows.Guid;
Item.Name.Text = “Ayman’s Item__”;
Item.Owner.Login = @”Server\Administrator”;
// Adding the Item to the zone
AZone.DashboardElements.Add(Item);
// Adding the zone to the page
APage.DashboardElements.Add(AZone);
// Adding the page to the dashboard
ADashboard_wows.Pages.Add(APage);
//Publishing
Publisher.CreateDashboard(ADashboard_wows);
}

}

Quick-Hit Technology Thoughts from a Territory Manager @ Nintex, Microsoft Regional Director and 6x Microsoft MVP