KPI(핵심 성과 지표) 표현(테이블 형식)
KPI는 기본 측정값으로 정의된 값을 대상 값과 비교하여 값 성과를 측정하는 데 사용됩니다.
KPI(핵심 성과 지표) 표현
테이블 형식 개체 모델에서 KPI(핵심 성과 지표)는 클라이언트 응용 프로그램에 대한 추가 정보를 그래픽으로 나타내는 측정값입니다. KPI에는 대개 달성해야 할 목표, 목표 대비 측정값의 상태 및 상태를 그래픽으로 보여 주는 방법을 제공하는 클라이언트 도구에 대한 정보가 포함되어 있습니다.
AMO의 핵심 성과 지표
AMO를 사용하여 테이블 형식 모델 KPI를 관리하는 경우 AMO의 KPI에 대해 일 대 일 개체 일치가 없습니다. AMO Kpi 개체는 이러한 용도로 사용되지 않습니다. 테이블 형식 모델에 대해 AMO의 KPI는 Commands 컬렉션 및 CalculationProperties에 있는 요소 중 하나에서 만들어진 일련의 개체로 표현됩니다.
다음 코드 조각에서는 여러 개의 가능한 KPI 정의 중 하나를 만드는 방법을 보여 줍니다.
private void addStaticKPI(object sender, EventArgs e)
{
double KPIGoal = 0, status1ThresholdValue = 0, status2ThresholdValue = 0
, redAreaValue = 0, yellowAreaValue = 0, greenAreaValue = 0;
string clientStatusGraphicImageName = "Three Circles Colored";
//Verify input requirements
//Goal values
if (staticTargetKPI.Checked)
{//Static KPI Goal selected
if (string.IsNullOrEmpty(staticTargetKPIGoal.Text)
|| string.IsNullOrWhiteSpace(staticTargetKPIGoal.Text)
|| !double.TryParse(staticTargetKPIGoal.Text, out KPIGoal))
{
MessageBox.Show(String.Format("Static Goal is not defined or is not a valid number."), "AMO to Tabular message", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
else
{//Measure KPI Goal selected
if (!TargetMeasureForKPISelected)
{
MessageBox.Show(String.Format("Measure Goal is not selected."), "AMO to Tabular message", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
//Status
if (string.IsNullOrEmpty(firstStatusThresholdValue.Text)
|| string.IsNullOrWhiteSpace(firstStatusThresholdValue.Text)
|| !double.TryParse(firstStatusThresholdValue.Text, out status1ThresholdValue)
|| string.IsNullOrEmpty(secondStatusThresholdValue.Text)
|| string.IsNullOrWhiteSpace(secondStatusThresholdValue.Text)
|| !double.TryParse(secondStatusThresholdValue.Text, out status2ThresholdValue))
{
MessageBox.Show(String.Format("Status Threshold are not defined or they are not a valid number."), "AMO to Tabular message", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(statusValueRedArea.Text)
|| string.IsNullOrWhiteSpace(statusValueRedArea.Text)
|| !double.TryParse(statusValueRedArea.Text, out redAreaValue)
|| string.IsNullOrEmpty(statusValueYellowArea.Text)
|| string.IsNullOrWhiteSpace(statusValueYellowArea.Text)
|| !double.TryParse(statusValueYellowArea.Text, out yellowAreaValue)
|| string.IsNullOrEmpty(statusValueGreenArea.Text)
|| string.IsNullOrWhiteSpace(statusValueGreenArea.Text)
|| !double.TryParse(statusValueGreenArea.Text, out greenAreaValue))
{
MessageBox.Show(String.Format("Status Area values are not defined or they are not a valid number."), "AMO to Tabular message", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
//Set working variables
string kpiTableName = ((DataRowView)MeasuresInModelList.CheckedItems[0])[0].ToString();
string kpiMeasureName = ((DataRowView)MeasuresInModelList.CheckedItems[0])[1].ToString();
//Verify if KPI is already defined
if (modelCube.MdxScripts["MdxScript"].CalculationProperties.Contains(string.Format("KPIs.[{0}]", kpiMeasureName)))
{
//ToDo: Verify with the user if wants to update KPI or exit
//If user wants to update then remove KPI from mdxScripts and continue with the creating the KPI
//
// Until the code to remove KPI is finished we'll have to exit with a message of no duplicated KPIs are allowed
MessageBox.Show(String.Format("Another KPI exists for the same measeure."), "AMO to Tabular message", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
StringBuilder kpiCommand = new StringBuilder();
AMO.MdxScript mdxScript = modelCube.MdxScripts["MdxScript"];
kpiCommand.Append(mdxScript.Commands[1].Text);
string goalExpression;
if (staticTargetKPI.Checked)
{//Static KPI Goal selected
goalExpression = KPIGoal.ToString();
}
else
{//Measure KPI Goal selected
string measureGoalMeasureName = ((DataRowView)KpiTargetMeasures.CheckedItems[0])[1].ToString();
goalExpression = string.Format("[Measures].[{0}]", measureGoalMeasureName);
}
kpiCommand.AppendLine(string.Format("CREATE MEMBER CURRENTCUBE.Measures.[_{1} Goal] AS '{2}', ASSOCIATED_MEASURE_GROUP = '{0}';"
, kpiTableName, kpiMeasureName, goalExpression));
string statusExpression;
if (staticTargetKPI.Checked)
{//Static KPI Goal selected
statusExpression = string.Format("KpiValue(\"{0}\")", kpiMeasureName).Trim();
}
else
{//Measure KPI Goal selected
string measureGoalMeasureName = ((DataRowView)KpiTargetMeasures.CheckedItems[0])[1].ToString().Trim();
string M = string.Format("[Measures].[{0}]", kpiMeasureName);
string T = string.Format("[Measures].[{0}]", measureGoalMeasureName);
if (KpiRelationDifference.Checked)
{
statusExpression = string.Format("{1} - {0}", M, T);
}
else
{
if (KpiRelationRatioMT.Checked)
{
statusExpression = string.Format("{0} / {1}", M, T);
}
else
{
statusExpression = string.Format("{1} / {0}", M, T);
}
}
}
kpiCommand.AppendLine(string.Format("CREATE MEMBER CURRENTCUBE.Measures.[_{1} Status] "
+ " AS 'Case When IsEmpty({9}) Then Null "
+ " When ({9}) {2} {3} Then {4} "
+ " When ({9}) {5} {6} Then {7} "
+ " Else {8} End'"
+ ", ASSOCIATED_MEASURE_GROUP = '{0}';"
, kpiTableName, kpiMeasureName // 0, 1
, statusThreshold1ComparisonOperator.Text, status1ThresholdValue, redAreaValue // 2, 3, 4
, statusThreshold2ComparisonOperator.Text, status2ThresholdValue, yellowAreaValue, greenAreaValue // 5, 6, 7, 8
, statusExpression // 9
));
kpiCommand.AppendLine(string.Format("CREATE MEMBER CURRENTCUBE.Measures.[_{1} Trend] AS '0', ASSOCIATED_MEASURE_GROUP = '{0}';"
, kpiTableName, kpiMeasureName));
kpiCommand.AppendLine(string.Format("CREATE KPI CURRENTCUBE.[{1}] AS Measures.[{1}]"
+ ", ASSOCIATED_MEASURE_GROUP = '{0}'"
+ ", GOAL = Measures.[_{1} Goal]"
+ ", STATUS = Measures.[_{1} Status]"
+ ", TREND = Measures.[_{1} Trend]"
+ ", STATUS_GRAPHIC = '{2}'"
+ ", TREND_GRAPHIC = '{2}';"
, kpiTableName, kpiMeasureName, clientStatusGraphicImageName));
{//Adding Calculation Reference for the Measure itself
if (!mdxScript.CalculationProperties.Contains(kpiMeasureName))
{
AMO.CalculationProperty cp = new AMO.CalculationProperty(kpiMeasureName, AMO.CalculationType.Member);
cp.FormatString = ""; // ToDo: Get formatting attributes for the member
cp.Visible = true;
mdxScript.CalculationProperties.Add(cp);
}
}
{//Adding Calculation Reference for the Goal measure
AMO.CalculationProperty cp = new AMO.CalculationProperty(string.Format("Measures.[_{0} Goal]", kpiMeasureName), AMO.CalculationType.Member);
cp.FormatString = ""; // ToDo: Get formatting attributes for the member
cp.Visible = false;
mdxScript.CalculationProperties.Add(cp);
}
{//Adding Calculation Reference for the Status measure
AMO.CalculationProperty cp = new AMO.CalculationProperty(string.Format("Measures.[_{0} Status]", kpiMeasureName), AMO.CalculationType.Member);
cp.FormatString = ""; // ToDo: Get formatting attributes for the member
cp.Visible = false;
mdxScript.CalculationProperties.Add(cp);
}
{//Adding Calculation Reference for the Status measure
AMO.CalculationProperty cp = new AMO.CalculationProperty(string.Format("Measures.[_{0} Trend]", kpiMeasureName), AMO.CalculationType.Member);
cp.FormatString = ""; // ToDo: Get formatting attributes for the member
cp.Visible = false;
mdxScript.CalculationProperties.Add(cp);
}
{//Adding Calculation Reference for the KPI
AMO.CalculationProperty cp = new AMO.CalculationProperty(string.Format("KPIs.[{0}]", kpiMeasureName), AMO.CalculationType.Member);
cp.FormatString = ""; // ToDo: Get formatting attributes for the member
cp.Visible = true;
mdxScript.CalculationProperties.Add(cp);
}
try
{
newDatabase.Update(AMO.UpdateOptions.ExpandFull, AMO.UpdateMode.UpdateOrCreate);
MessageBox.Show(String.Format("KPI successfully defined."), "AMO to Tabular message", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (AMO.OperationException amoOperationException)
{
//ToDo: remove anything left in mdxScript up to the point where the exception was thrown
MessageBox.Show(String.Format("Error creating KPI for Measure '{0}'[{1}]\nError message: {2}", kpiTableName, kpiMeasureName, amoOperationException.Message), "AMO to Tabular message", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
AMO2Tabular 예제
AMO를 사용하여 핵심 성과 지표 표현을 만들고 조작하는 방법을 알아보려면 AMO to Tabular 예제의 원본 코드를 참조하십시오. 특히 원본 파일 AddKPIs.cs에서 확인하십시오. 이 예제는 Codeplex에 있습니다. 코드에 대한 중요 정보: 코드는 여기에서 설명한 논리적 개념에 대한 지원으로만 제공되며 프로덕션 환경에서 사용해서는 안 됩니다. 그리고 교육 목적 이외의 목적으로는 사용할 수 없습니다.