Using the Form Designer, you can create a dashboard to show graphs and list key figures for your company. This tutorial requires the AP Module.
This tutorial will show you how to display the Budget vs Actual for the Top 5 Expenses for the last 12 Months.
Note: You can also use this tutorial to show the Budget vs Actual for the Top 5 Sales Groups for the last 12 Months. See FD Tutorial: Dashboard Budget vs Actual Sales Groups.
No. |
Name |
Display Label |
Type |
Domain |
Size |
Width |
Req |
Visible |
1 |
ExpenseCode |
Expense |
String |
|
10 |
10 |
|
Selected |
2 |
Expense |
Actual |
Float |
Amount |
|
10 |
|
Selected |
3 |
ExpBudget |
Budget |
Float |
Amount |
|
10 |
|
Selected |
Property |
Value |
Description |
BackWallColor |
clWhite |
Click the [...] button in BackWallColor, and click white, to set the graph back wall to white. |
Height |
132 |
Sets the graph height. You can also drag to change the height. |
Left |
10 |
Moves the graph to the left of the form. |
ShowGridLines |
False |
Hides the grid lines. |
Top |
32 |
Sets the graph position from the top. You can also drag to change the position. |
Width |
600 |
Sets the graph width. You can also drag to change the width. |
Field Name |
Display Label |
Show Key Border |
Pen Style |
Pen Width |
Expense |
Actual |
|
psSolid |
1 |
ExpBudget |
Budget |
|
psSolid |
1 |
You can now write the MaxBasic code to populate the Memory Table and graph.
Sub RefreshBudget
Dim ExpenseCodes as String
PeriodToUse = CurrentPeriod("AP")
StartPeriod = AddPeriod(PeriodToUse, -12,True)
EndPeriod = AddPeriod(PeriodToUse, -1,True)
SQLExpenseCode = "SELECT Min(APANLBAL.PeriodID) as PeriodID " & _
" ,Min(APANLBAL.AnalysisCode) as ExpenseCode " & _
" ,Sum(APANLBAL.Budget) as ExpBudget " & _
" ,Sum(APANLBAL.PeriodActivity) as Expense " & _
"FROM APANLBAL " & _
"WHERE APANLBAL.PeriodID Between :StartPeriod AND :EndPeriod " & _
"Group BY ExpenseCode " & _
"Order BY Expense DESC "
tblExpenseCode = ExecuteSQL(SQLExpenseCode,StartPeriod,EndPeriod)
Counter = 0
tblGraphBudgetExp.empty
tblGraphBudgetExp.AllowInsertDelete = True
tblExpenseCode.First
Do Until tblExpenseCode.EOF or (Counter >= 5)
tblGraphBudgetExp.Append
tblGraphBudgetExp.ExpenseCode = tblExpenseCode.ExpenseCode
tblGraphBudgetExp.ExpBudget = FormatNumber(tblExpenseCode.ExpBudget, "$0.00")
tblGraphBudgetExp.Expense = FormatNumber(tblExpenseCode.Expense, "$0.00")
Counter = Counter + 1
tblGraphBudgetExp.Save
tblExpenseCode.Next
Loop
tblGraphBudgetExp.AllowInsertDelete = False
graphBudgetExpense.RefreshData
End Sub
Sub OnCreate
RefreshBudget
End Sub
(Ctrl+S).(Ctrl+R) to test the form.