Articles in this section
Category / Section

How to display the measure name instead of showing "Measures" in AxisElementBuilder ?

1 min read

This KB illustrates that how to display the measure name instead of showing “Measures”  AxisElementBuilder.

Solution

Displaying measure name instead of showing “Measures” in SplitButton in AxisElementBuilder can be achieved through the following code example.

C#

protected void Page_Load(object sender, EventArgs e)
{
     this.OlapClient1.AxisElementBuilderColumn.PreRender += AxisElementBuilderColumn_PreRender;
}
void AxisElementBuilderColumn_PreRender(object sender, EventArgs e)
{
    int i = 0;
    foreach (var spltBtn in this.OlapClient1.AxisElementBuilderColumn.SplitButtonCollection.Values)
    {
        if ((spltBtn.Controls[0] as Label).Text == "Measures" && this.OlapClient1.OlapDataManager.CurrentReport.CategoricalElements[i].ElementValue is MeasureElements)
        {
             (spltBtn.Controls[0] as Label).Text = (this.OlapClient1.OlapDataManager.CurrentReport.CategoricalElements[i].ElementValue as MeasureElements).Elements[0].Name;
             //Or if you have assigned only unique name in report you can manipulate the string below accordingly to get the measure name.
             (spltBtn.Controls[0] as Label).Text = (this.OlapClient1.OlapDataManager.CurrentReport.CategoricalElements[i].ElementValue as MeasureElements).Elements[0].UniqueName.Replace("[","").Replace("]","").Replace(".","").Replace("Measures","");
         }
         i++;
     }
}

VB

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
  AddHandler Me.OlapClient1.AxisElementBuilderColumn.PreRender, AddressOf AxisElementBuilderColumn_PreRender
End Sub
Private Sub AxisElementBuilderColumn_PreRender(ByVal sender As Object, ByVal e As EventArgs)
 Dim i As Integer = 0
 For Each Dim spltBtn In Me.OlapClient1.AxisElementBuilderColumn.SplitButtonCollection.Values
  If (TryCast(spltBtn.Controls(0), Label)).Text = "Measures" AndAlso TypeOf Me.OlapClient1.OlapDataManager.CurrentReport.CategoricalElements(i).ElementValue Is MeasureElements Then
    (TryCast(spltBtn.Controls(0), Label)).Text = (TryCast(Me.OlapClient1.OlapDataManager.CurrentReport.CategoricalElements(i).ElementValue, MeasureElements)).Elements(0).Name
    'Or if you have assigned only unique name in report you can manipulate the string below accordingly to get the measure name.
    (TryCast(spltBtn.Controls(0), Label)).Text = (TryCast(Me.OlapClient1.OlapDataManager.CurrentReport.CategoricalElements(i).ElementValue, MeasureElements)).Elements(0).UniqueName.Replace("[","").Replace("]","").Replace(".","").Replace("Measures","")
  End If
   i += 1
 Next spltBtn
End Sub

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied