I assume you're grouping by year. I would create a couple of running total sums. Since you don't mention your field names, I'm going to use "Money_Type" in this sample as the field that determines whether it's Revenue or Cost and "Amount" as the dollar value.
1. In the Running Total Expert, select the Amount field as the Field to Summarize and make the running total a SUM. Call this running total "Revenue"
2. Evaluate: Use a Formula. In the Formula Editor, use a formula like this:
{Table.Money_Type} = 'Revenue'
3. Reset On Change Of Group and select your year group. If you're not grouping on year and instead are just selecting a single year as a parameter, chose Reset Never instead.
4. Create another running total for Cost.
5. Create a formula for your Gross Margin: {#Revenue} - {#Cost}
-Dell