Custom Aggregate Function

Stimulsoft Reports.Net discussion
Post Reply
ivar
Posts: 17
Joined: Tue Aug 04, 2015 11:41 am

Custom Aggregate Function

Post by ivar » Thu May 07, 2020 12:36 pm

Hello,

I have registered a custom aggregate function using:

Code: Select all

StiOptions.Services.AggregateFunctions.Add(new SumMoneyFunctionService());
This aggregate function doesn't work when the report calculation mode is 'Interpretation'

Is there a way to make it work?

Regards, Ivar
Lech Kulikowski
Posts: 2575
Joined: Tue Mar 20, 2018 5:34 am

Re: Custom Aggregate Function

Post by Lech Kulikowski » Mon May 11, 2020 7:05 am

Hello,

Please try to use the following code for adding custom functions:

Code: Select all

public class MyFunction
{
    private const string Category = "MyFuncCategory";

    public static string MyFunc(string value)
    {
        return value.ToUpper();
    }

    public static void RegisterFunctions()
    {
        var ParamNames = new string[1];
        var ParamTypes = new Type[1];
        var ParamDescriptions = new string[1];

        ParamNames[0] = "value";
        ParamDescriptions[0] = "Descriptions";
        ParamTypes[0] = typeof(string);

        Stimulsoft.Report.Dictionary.StiFunctions.AddFunction(Category, "MyFunc", "MyFunc", "Description", typeof(MyFunction),
                                 typeof(string), "Return Description", ParamTypes, ParamNames, ParamDescriptions);
    }
}
Thank you.
ivar
Posts: 17
Joined: Tue Aug 04, 2015 11:41 am

Re: Custom Aggregate Function

Post by ivar » Mon May 11, 2020 7:42 am

Thanks,

I used that to add custom functions for expressions and it works.

But how do I add a function to sum multiple lines like in the screenshot?

Regards, Ivar
Attachments
Untitled.png
Untitled.png (18.96 KiB) Viewed 415 times
HighAley
Posts: 8272
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Custom Aggregate Function

Post by HighAley » Tue May 12, 2020 9:27 pm

Hello,

Sorry, there is no way to do this.
Different report events are used for the calculations.
You could use the events to make your calculations.

Thank you.
ivar
Posts: 17
Joined: Tue Aug 04, 2015 11:41 am

Re: Custom Aggregate Function

Post by ivar » Thu May 14, 2020 10:09 am

ok, not really what I wanted to hear but thanks anyway.
HighAley
Posts: 8272
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Custom Aggregate Function

Post by HighAley » Thu May 14, 2020 12:23 pm

Hello.

Anyway you have to add code to report events and there is no way to get it using the custom function.
As a way you could try to do it in our source code. It's available for purchase.

Thank you.
ivar
Posts: 17
Joined: Tue Aug 04, 2015 11:41 am

Re: Custom Aggregate Function

Post by ivar » Thu May 14, 2020 6:03 pm

I'll see what I can achieve with the report events. The problem is that many reports would need this custom code and our customers wouldn't know how to edit them without breaking the report. But I can solve it by calculating the totals in the businessobjects beforehand so I have a workaround.

Source code is not really an option I'm afraid. As soon as we start adding our own code we have to maintain it. I already have thousands of lines of code to maintain. I rather use the library as-is as long as most of what we want to achieve is possible.

Thanks for the information.
Lech Kulikowski
Posts: 2575
Joined: Tue Mar 20, 2018 5:34 am

Re: Custom Aggregate Function

Post by Lech Kulikowski » Tue May 19, 2020 6:59 am

Hello

Ok.
Please let us know if you need any additional help.

Thank you.
Post Reply