This tutorial will show you how to create a report to show sales by Period in a graph.
Alt+Q). Between :FromPeriod and :ToPeriod
,ARAREBAL.PeriodActivity line, before the FROM ARAREA line. In the new line type:,PeriodEndDate(ARAREBAL.PeriodID) as DatePeriods
Alt+C). This will add add the :FromPeriod and :ToPeriod parameters to the Results tab.Alt+C) to check the query for errors. If no errors are found, click F9).F9). The Wizard will generate a report listing all the results of the query. F3):' See AfterQuery code for code relating to the graph
Dim tblGraph as Object
' Create a list of colours to be used in the graph
Dim ColorsForGraph as Object
ColorsForGraph = CreateObject("Accredo.StringList")
ColorsForGraph.CommaText = "red,blue,green,yellow,cyan,pink,silver,brown,purple,teal"
If not Query.IsEmpty Then
'Clone the report query and pivot to create the memory table for the graph
tblGraph = PivotTable(CloneQuery,"DatePeriods","SalesAreaCode","Sum(PeriodActivity)",False)
graph1.Table = tblGraph
graph1.XDataFieldName = "DatePeriods"
graph1.XLabelFieldName = "DatePeriods"
'Dynamically add the graph fields based on the pivot table
TotalFields = tblGraph.Fields.Count
graph1.ClearAllFields
For x = 0 to TotalFields - 1
tblGraph.Fields.Item(x).DisplayLabel = Replace(tblGraph.Fields.Item(x).DisplayLabel, " PeriodActivity", "")
If x > 1 then
graphField = Graph1.AddField(tblGraph.Fields.Item(x).FieldName)
graphField.DisplayLabel = tblGraph.Fields.Item(x).DisplayLabel
graphField.BrushColor = ColorByName(ColorsForGraph[(X-2) Mod ColorsForGraph.Count])
End If
Next x
End If
Ctrl+R) to run the report.Note: A similar report is provided with Accredo. See the ARSalesAreasByPeriodGraph.pfd report. That report displays figures by PeriodID, rather than Period End Date in this report, so gives slightly different results when periods are in different financial years.