Category / Section
How to select the top "n" records from the Cube in Silverlight ?
1 min read
You can select the top n records from the Cube by using the TopCountElement in the OlapReport.
C#
OlapReport olapReport = new OlapReport(); olapReport.Name = "Customer Report"; olapReport.CurrentCubeName = "Adventure Works"; DimensionElement dimensionElementColumn = new DimensionElement(); //Specifies the Name for the Dimension Element. dimensionElementColumn.Name = "Customer"; dimensionElementColumn.AddLevel("Customer Geography", "Country"); //Creates the Measure Element. MeasureElements measureElementColumn = new MeasureElements(); measureElementColumn.Elements.Add(new MeasureElement { Name = "Internet Sales Amount" }); DimensionElement dimensionElementRow = new DimensionElement(); //Specifies the Dimension Name. dimensionElementRow.Name = "Date"; dimensionElementRow.AddLevel("Fiscal", "Fiscal Year"); //Filters the top 5 elements of the "Internet Sales Amount". TopCountElement topCountElement = new TopCountElement(AxisPosition.Categorical, 5); topCountElement.MeasureName = "Internet Sales Amount"; /// Adds the Column Members. olapReport.CategoricalElements.Add(dimensionElementColumn); ///Adds the Measure Element. olapReport.CategoricalElements.Add(measureElementColumn); ///Adds the Measure Element. olapReport.CategoricalElements.Add(topCountElement); ///Adds the Row Members. olapReport.SeriesElements.Add(dimensionElementRow);
VB
Dim olapReport As OlapReport = New OlapReport() olapReport.Name = "Customer Report" olapReport.CurrentCubeName = "Adventure Works" Dim dimensionElementColumn As DimensionElement = New DimensionElement() 'Specifeis the Name for the Dimension Element. dimensionElementColumn.Name = "Customer" dimensionElementColumn.AddLevel("Customer Geography", "Country") 'Creates the Measure Element. Dim measureElementColumn As MeasureElements = New MeasureElements() measureElementColumn.Elements.Add(New MeasureElement With {.Name = "Internet Sales Amount"}) Dim dimensionElementRow As DimensionElement = New DimensionElement() 'Specifies the Dimension Name. dimensionElementRow.Name = "Date" dimensionElementRow.AddLevel("Fiscal", "Fiscal Year") 'Filters the top 5 elements of "Internet Sales Amount". Dim topCountElement As TopCountElement = New TopCountElement(AxisPosition.Categorical, 5) topCountElement.MeasureName = "Internet Sales Amount" ''' Adds the Column Members. olapReport.CategoricalElements.Add(dimensionElementColumn) '''Adds the Measure Element. olapReport.CategoricalElements.Add(measureElementColumn) '''Adds the Measure Element. olapReport.CategoricalElements.Add(topCountElement) '''Adds the Row Members. olapReport.SeriesElements.Add(dimensionElementRow)