Hi Peter,
Unfortunately, this falls into a "you can't get there from here" realm. I assume you are looking for margin % on groups such as departments and categories.
As you noticed, the averaging in RMS simply averages the contents of the column so you can't get a proper margin percentage.
To achieve accurate margin, there are a few approaches, but ultimately, you need to calculate the average on the sums of sales and cost so will need to use an aggregate report. I have pasted a sample below which calculates margin by category. If you paste it into notepad and save as "Custom - Category Margin.qrp" in the reports directory, you should be on your way.
//--- Report Summary --- //
Begin ReportSummary
ReportType = reporttypeSales
ReportTitle = "Category Margin Report"
PageOrientation = pageorientationPortrait
OutLineMode = True
Groups = 1
GroupDescription = ""
DisplayLogo = True
LogoFileName = "MyLogo.bmp"
ProcedureCall = ""
TablesQueried = "FROM TransactionEntry WITH(NOLOCK) INNER JOIN [Transaction] WITH(NOLOCK) ON TransactionEntry.TransactionNumber = [Transaction].TransactionNumber LEFT JOIN Item WITH(NOLOCK) ON TransactionEntry.ItemID = Item.ID LEFT JOIN Department WITH(NOLOCK) ON Item.DepartmentID = Department.ID LEFT JOIN Category WITH(NOLOCK) ON Item.CategoryID = Category.ID "
SelCriteria = ""
GroupBy = "Category.Name"
SortOrder = ""
End ReportSummary
//--- Title Rows ---//
Begin TitleRow
Text = "<Store Name>"
Font = "Arial"
FontBold = True
FontSize = 16
Color = "Blue"
End TitleRow
Begin TitleRow
Text = "<Report Title>"
Font = "Arial"
FontBold = True
FontSize = 12
Color = "Black"
End TitleRow
Begin TitleRow
Text = "Generated On <Report Date>"
Font = "Arial"
FontBold = True
FontSize = 10
Color = "Black"
End TitleRow
//--- Filters ---//
Begin Filter
FieldName = "[Transaction].Time"
FilterOp = reportfilteropBetween
FilterLoLim = "<MonthStart>"
FilterHilim = "<Today>"
End Filter
//--- Columns ---//
Begin Column
FieldName = "Category.Name"
DrillDownFieldName = "Category.Name"
DrillDownReportName = ""
Title = "Category"
VBDataType = vbString
Formula = ""
ColHidden = False
ColNotDisplayable = False
FilterDisabled = False
ColWidth = 2070
GroupMethod = groupmethodNone
ColFormat = ""
End Column
Begin Column
FieldName = "DName"
DrillDownFieldName = "Department.Name"
DrillDownReportName = ""
Title = "Department"
VBDataType = vbString
Formula = "MAX(Department.Name)"
ColHidden = True
ColNotDisplayable = False
FilterDisabled = False
ColWidth = 2505
GroupMethod = groupmethodNone
ColFormat = ""
End Column
Begin Column
FieldName = "[Transaction].Time"
DrillDownFieldName = ""
DrillDownReportName = ""
Title = "Date"
VBDataType = vbDate
Formula = ""
ColHidden = True
ColNotDisplayable = True
FilterDisabled = False
ColWidth = 1335
GroupMethod = groupmethodNone
ColFormat = ""
End Column
Begin Column
FieldName = "Sales"
DrillDownFieldName = ""
DrillDownReportName = ""
Title = "Sales"
VBDataType = vbCurrency
Formula = "SUM(TransactionEntry.Price * TransactionEntry.Quantity)"
ColHidden = False
ColNotDisplayable = False
FilterDisabled = False
ColWidth = 1290
GroupMethod = groupmethodSum
ColFormat = ""
End Column
Begin Column
FieldName = "Cost"
DrillDownFieldName = ""
DrillDownReportName = ""
Title = "Cost"
VBDataType = vbCurrency
Formula = "SUM(TransactionEntry.Cost * TransactionEntry.Quantity)"
ColHidden = False
ColNotDisplayable = False
FilterDisabled = False
ColWidth = 1320
GroupMethod = groupmethodSum
ColFormat = ""
End Column
Begin Column
FieldName = "Profit"
DrillDownFieldName = ""
DrillDownReportName = ""
Title = "Profit"
VBDataType = vbCurrency
Formula = "SUM(TransactionEntry.Price * TransactionEntry.Quantity) - SUM(TransactionEntry.Cost * TransactionEntry.Quantity)"
ColHidden = False
ColNotDisplayable = False
FilterDisabled = False
ColWidth = 1380
GroupMethod = groupmethodSum
ColFormat = ""
End Column
Begin Column
FieldName = "Margin"
DrillDownFieldName = ""
DrillDownReportName = ""
Title = "Margin"
VBDataType = vbDouble
Formula = "(SUM(TransactionEntry.Price * TransactionEntry.Quantity) - SUM(TransactionEntry.Cost * TransactionEntry.Quantity))/(SUM(TransactionEntry.Price * TransactionEntry.Quantity))"
ColHidden = False
ColNotDisplayable = False
FilterDisabled = False
ColWidth = 1380
GroupMethod = groupmethodAverage
ColFormat = "#.##%"
End Column