This KB illustrates that how to select top "n" records from Cube. SolutionYou can select the top “n” records from the Cube by using TopCountElement in OlapReport. C#OlapReport olapReport = new OlapReport();olapReport.Name = "Customer Report";olapReport.CurrentCubeName = "Adventure Works"; DimensionElement dimensionElementColumn = new DimensionElement();//Specifying the Name for the Dimension ElementdimensionElementColumn.Name = "Customer";dimensionElementColumn.AddLevel("Customer Geography", "Country"); //Creating Measure ElementMeasureElements measureElementColumn = new MeasureElements();measureElementColumn.Elements.Add(new MeasureElement { Name = "Internet Sales Amount" }); DimensionElement dimensionElementRow = new DimensionElement();//Specifying the Dimension NamedimensionElementRow.Name = "Date";dimensionElementRow.AddLevel("Fiscal", "Fiscal Year"); //Filter the top 5 elements of "Internet Sales Amount".TopCountElement topCountElement = new TopCountElement(AxisPosition.Categorical, 5);topCountElement.MeasureName = "Internet Sales Amount"; /// Adding Column MembersolapReport.CategoricalElements.Add(dimensionElementColumn);///Adding Measure ElementolapReport.CategoricalElements.Add(measureElementColumn);///Adding Measure ElementolapReport.CategoricalElements.Add(topCountElement);///Adding Row MembersolapReport.SeriesElements.Add(dimensionElementRow); VBDim olapReport As OlapReport = New OlapReport() olapReport.Name = "Customer Report" olapReport.CurrentCubeName = "Adventure Works" Dim dimensionElementColumn As DimensionElement = New DimensionElement() 'Specifying the Name for the Dimension Element dimensionElementColumn.Name = "Customer" dimensionElementColumn.AddLevel("Customer Geography", "Country") 'Creating Measure Element Dim measureElementColumn As MeasureElements = New MeasureElements() measureElementColumn.Elements.Add(New MeasureElement With {.Name = "Internet Sales Amount"}) Dim dimensionElementRow As DimensionElement = New DimensionElement() 'Specifying the Dimension Name dimensionElementRow.Name = "Date" dimensionElementRow.AddLevel("Fiscal", "Fiscal Year") 'Filter the top 5 elements of "Internet Sales Amount". Dim topCountElement As TopCountElement = New TopCountElement(AxisPosition.Categorical, 5) topCountElement.MeasureName = "Internet Sales Amount" ''' Adding Column Members olapReport.CategoricalElements.Add(dimensionElementColumn) '''Adding Measure Element olapReport.CategoricalElements.Add(measureElementColumn) '''Adding Measure Element olapReport.CategoricalElements.Add(topCountElement) '''Adding Row Members olapReport.SeriesElements.Add(dimensionElementRow)
|
This page will automatically be redirected to the sign-in page in 10 seconds.