Creating conditional total rows in SSRS

2019-07-18 06:38发布

问题:

I am creating a report that has to mimic and existing report… it has grand totals and subtotals.

Problem is the subtotals are based on different criteria…

So:

Apples           5
Oranges          6
Beans            3
Grapes           8
Peas             3

Total Fruit:    19
Total Veggies:  6
Grand Total :   25

Assuming I have a field that tells me if an item is Fruit/Veggie, how can I create grand subtotal row (at the bottom of the page) that will only add based on the value of another field?

I do not want separate groups. The format should remain as is.

回答1:

Add calculated fields to the underlying dataset that total Fruit and Veggies separately. That way the appropriate sub total can be based on the calulated field.

If you had a field that was ItemType, containing "Fruit" and "Vegetable", you could create a function like =Sum(Iif(Fields![ItemType]="Fruit",1,0)) to sum only the fruit.