Page 1 of 1

Using Running Total as condition

Posted: Sat Jul 16, 2016 3:49 am
by beginner
I'm displaying running total for a field, and I like to apply a filter based on that. Unfortunately, neither Datasource's `filters` nor field's `conditions` allows me to use this function, and I'll get `Stimulsoft.Report.Totals does not contain a definition for SumRunning` exception.

The condition that I like to format cells and filter data source with is

Code: Select all

SumRunning(GroupHeaderBand1,DataSource1.Qnty) < 0
.


I'll be grateful if you could help me.

Thanks in advance,

Re: Using Running Total as condition

Posted: Mon Jul 18, 2016 2:39 pm
by HighAley
Hello.

Please, send us your report template with sample data for analysis.
Also describe more detailed where and how you want to use this function.

Thank you.

Re: Using Running Total as condition

Posted: Tue Aug 30, 2016 9:21 am
by beginner
Hi,

I'd like to filter data based on that. Let's say to show items with minus `running total`. I have tried to put it Datasource's filter section.
I tested and I can put other functions like `abs` in that section, but not `sumRunning`.

Unfortunately, I'm not able to send you test data, but I'll be very grateful if you could guide me without that.

Re: Using Running Total as condition

Posted: Tue Aug 30, 2016 1:41 pm
by HighAley
Hello.

The Filter is applied before showing the Data Band, so it's impossible to use it this way.
As a way you could add a variable and calculate the running total there in the Before Print event of the Band and change Enabled property of the Data Band.
Here is sample code of the Before Print event:

Code: Select all

Running += Orders.Freight;

if (Running > 300) {
	DataOrders.Enabled = false;
} else {
	DataOrders.Enabled = true;
}
Or you could use the Conditions.

Thank you.

Re: Using Running Total as condition

Posted: Wed Aug 31, 2016 3:00 am
by beginner
Thanks HighAley,

Your solution works just fine.
I'm using it in a report with 2 `Group headers`. The first one is a Warehouse group and the second one is a Item group that shows items in that particular warehouse. With the following code I can disable the second group, but it would have been great to be able to disable the first group (warehouse) if it doesn't have any good with the specified condition.

Code: Select all

bool enabled = true;
decimal running = 0;

running += DataSource1.Qnty;
if (running < 0)
  enabled = false;

GroupHeaderBand1.Enabled = DataDataSource1.Enabled = enabled;

Is there any way to check for empty children, in the `before print` event of the first group band?

Re: Using Running Total as condition

Posted: Wed Aug 31, 2016 7:34 am
by HighAley
Hello.

You could try to use the Double Pass mode.
Check if there any data at the First pass and disable groups on the second.

Thank you.