RD Tutorial: Report IC Product Sales with Percent of Total
This tutorial will show you how to create a report to show the IC Product Sales for a period, and for each product, the percentage of the total sales.
Go to Navigator > Setup > Report Designer to open the Report Designer. First, create a SQL Query to return the Products sold, Descriptions and Sales Value for a particular period. Click Edit Query (Alt+Q). Select the ICPROD (IC Products) and the ICBAL (IC Balances) tables. These will be joined by the ProductCode fields. Select the following fields:ICPROD.ProductCode ICPROD.Description ICBAL.SalesValue ICBAL.PeriodID Set ICBAL.PeriodID to be hidden, by un-ticking the column. Set the ICBAL.PeriodID to have a parameter for the period required, by setting the column to: = :AsAtPeriod
Set the for the ICBAL.SalesValue to not include zero value sales:<> 0
Group the results by the Product Code, by selecting the column. Click Check Query (Alt+C) to check the query for errors. Click on the Results tab. For the AsAtPeriod Param set the Type to Number and Value to the current Period ID, or just use 101. Click Accept (F9). In the Report Designer, click the Report Wizard button, or go to Accredo > File > Report Wizard. In the Report Design Wizard form, set the following:Report Title: Product Sales Selections Title: Report Selections Retain BeforeReport Code: Unselected (Clear) Retain AfterQuery Code: Selected (Ticked) Leave the defaults in the Columns tab. In the Selections tab, set the following for AsAtPeriod:Caption: As at Input Type: Period Style: Equal If Blank: Required Default Value: CurrentPeriod("IC") Click Generate (F9). The Wizard will generate a report. Select the Report, then click the property. Enter the following code to sum the total sales after the query is executed:Dim tblSales as Object tblSales = CloneQuery tblSales.First Do Until tblSales.EOF TotalSales = TotalSales + tblSales.SalesValue tblSales.Next Loop tblSales = nothing
Select the Report, then click the property. Add the following as the first line, before the existing code:TotalSales = 0
Select the bandStandard Detail Band. Enter the following in the section:PercentOfTotalSales = Percent(Query.SalesValue,TotalSales)
Select the bandTotal Summary Band. Enter the following in the section:PercentOfTotalSales = Percent(TotalSalesValue,TotalSales)
Add a new label , next to the Sales Value label in the Column Header Band. You could copy the Sales Value label then resize it. Change the Text to:% Of Total Sales
Add a new expression , next to the Query.SalesValue expression in the Detail band. You could copy the Query.SalesValue expression then resize it. Set the Format to Percent. Change the Expression to:PercentOfTotalSales
Add a new expression , next to the TotalSalesValue expression in the Summary band. You could copy the TotalSalesValue expression then resize it. Set the Format to Percent. Change the Expression to:PercentOfTotalSales
Save the report, then click Execute Report (Ctrl+R) to run the report. Note: This report is provided with Accredo. See the ProductSalesWithPercentOfTotalSales.pfd report.