This is a migrated thread and some comments may be shown as answers.

Sum for only items showed

22 Answers 387 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Xuan Truong
Top achievements
Rank 1
Xuan Truong asked on 30 Sep 2011, 12:59 AM
I have a report displayed as below :
Crosstab with row group ID :
            ID    Qty        Items
            1     3            P1
                                 P2
                                 P3
            2     2            C1
                                 C2
---------------------------------
Total Qty=  13
Using Sum(Fields.Qty), result = 13 ( = sum all rows)
How to get sum(Fields.Qty) = 5 ? (only items Qty displayed in report)
Thanks.

22 Answers, 1 is accepted

Sort by
0
Xuan Truong
Top achievements
Rank 1
answered on 30 Sep 2011, 06:31 PM
Sorry, who can help me?
I used function Exec("crosstab1", sum(Fields.Qty) but result = 13.
=> Please advise me best solution.
0
Xuan Truong
Top achievements
Rank 1
answered on 01 Oct 2011, 05:45 PM
Actually Telerik reporting can not solve above problem ?
i spent many days to find solution but now can not .
Can any one help me ? Thanks very  much.
0
Steve
Telerik team
answered on 04 Oct 2011, 03:53 PM
Hello Tran,

Aggregate functions would work on the whole set of data and this is expected. Data-scope functions work on specified scope and in your case the scope you have set is "crosstab1" which is the data item itself i.e. again the aggregate function would be executed over the whole data.
If you need to execute an aggregate under a different scope i.e. a row/column group, you need to specify it as first argument e.g. = Exec("rowgroupID", sum(Fields.Qty))

Kind regards,
Steve
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Xuan Truong
Top achievements
Rank 1
answered on 04 Oct 2011, 05:35 PM
I've tried it, but no result. I received an message : An error occurred while processing TextBox 'TextBox10' ; Invalid scope : 'ID_PTC' (althought there are 1 row group 'ID_PTC')
Please see attach file : designer and result picture.
Please advise me .
Thanks.
0
Massimiliano Bassili
Top achievements
Rank 1
answered on 06 Oct 2011, 01:30 PM
I can't say from the screens whether your item is in containing scope of your group. Note what the Expression scope article says: "A named scope can be the name of a data item, or a group. You must specify the current scope or a containing scope; you cannot specify a scope that is lower or at the same level in containment order than the current scope."

Cheers!
0
Xuan Truong
Top achievements
Rank 1
answered on 08 Oct 2011, 03:02 AM
Please check pic below and advise me.
I want only show a total for field Qty (grouped) in textBox2. I don't understand exactly your tutorial and how to apply in this case :
ID_PTC    Qty=5        Items
            1     3                P1
                                      P2
                                      P3
---------------------------------------
            2     2                 C1
                                      C2
---------------------------------------
Thanks.
0
Steve
Telerik team
answered on 12 Oct 2011, 01:59 PM
Hello Xuan,

As I said in my previous post, aggregate functions work on the whole set of data. If Sum(Fields.Qty) returns 13 as result (i.e. the sum of all rows) then this result is expected. Please elaborate on what base you expect the Sum(Fields.Qty) to return 5 instead? Where are the 3 and 2 values coming from? Are those only the first values for a group i.e. Sum(First(Fields.Qty)) in other words are you trying to create a nested aggregate?

Regards,
Steve
the Telerik team

Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.

0
Xuan Truong
Top achievements
Rank 1
answered on 12 Oct 2011, 10:21 PM
Sorry, I have a table as below :
ID_PTC      Qty              Items
            1       3                P1
            1       3                P2
            1       3                P3
---------------------------------------
            2       2                 C1
            2       2                 C2
---------------------------------------

In Designer, I set 2 Crosstab Row group as below :
Name                                  Item                           Grouping                    
ID_PTC                               textBox6                    Fields.ID_PTC
     (DetailGroup)                                                   Fields.Item

Then Table will display as below :
ID_PTC      Qty              Items
            1       3                P1
                                       P2
                                       P3
---------------------------------------
            2       2                 C1
                                        C2
---------------------------------------


If I set TableHeader "Qty" as : Qty = {Sum(Fields.Qty)} => result : Qty = 13
But I want only Qty =5 ( sum of 2 and 3 ) such as idea : Qty= {Sum(First(Fields.Qty). } But report show err : "Agregate/RowNumber/columNumber  function can not be nested."
Please, help how to solve this problem?
Thanks.
0
Squall
Top achievements
Rank 1
answered on 17 Oct 2011, 05:47 PM
Hi,
You can't use nested aggregates with telerik reports. However I am very sure that you can do that with a custom aggregate that sums only the first group value.
SN
0
Kapil
Top achievements
Rank 1
answered on 20 Dec 2012, 02:57 PM
Hi 
I want the functionality of nested aggregation like "Sum(First(Fields.Qty))". Please help me to achieve this functionality
thanks..  

0
Jitendra
Top achievements
Rank 1
answered on 04 Jun 2015, 12:20 PM

Hello Sqaull,

 I am facing the same problem what Xuan mention , can you please explain little  bit how we can acheive through custom aggregate ?

 Thanks,

0
Ramya
Top achievements
Rank 1
answered on 05 Dec 2016, 02:40 PM
I have a cross tab where I have used aggregation to find the max in a group. At the end I need to display the total of  all max values. Please let me know if this can be achieved?
0
Katia
Telerik team
answered on 06 Dec 2016, 12:50 PM
Hello Ramya,

This scenario requires additional logic to be added to the report processing (using report events). You can save the processing maximum value for each group in TextBox ItemDataBound event in a variable and then use this variable to set the value for the TextBox showing the sum of maximum value.

A sample report demonstrating this approach is attached.


Regards,
Katia
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Ramya
Top achievements
Rank 1
answered on 06 Dec 2016, 03:43 PM

Hi Katia,

This solution worked.  Thanks for the help.

Regards,

Ramya

0
Ravi
Top achievements
Rank 1
answered on 02 Mar 2017, 05:31 AM

Hi I am looking for Cross tab Total.

It seems to be summing all the values.but i need what ever the values present in the report it has to sum only.

If choose only one month in filter,it has to show only one moth.

Please reply asp.

Here i attached file.

0
Katia
Telerik team
answered on 03 Mar 2017, 12:30 PM
Hi Ravi,

In order to filter the data in the report based on the value of report parameter you need to apply filter rules to the data item or to use data source parameters to filter the data upon retrieval.
For more detailed information check Filtering Data section.

Example of the filtering applied on report level can be found in Employee Sales demo report. It is located also in Telerik Reporting instalaltion folder if you need to check the settings of this report.

Example of the filtering applied on data source level is demonstrated in Invoice report which is also located in installation folder.


Regards,
Katia
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Ravi
Top achievements
Rank 1
answered on 28 Mar 2017, 04:15 AM
Thanks Man,It is  working.
0
Ravi
Top achievements
Rank 1
answered on 28 Mar 2017, 04:15 AM
Thanks Man, it is working
0
vikas
Top achievements
Rank 1
answered on 27 Mar 2018, 11:28 AM

Hi 

i want to use Aggregates function in telerik report designer like (Sum,Max,Min). i am using telerik report designer .trdx file. Can you please provide example with syntax to how we use this.

Thanks

0
Argie
Top achievements
Rank 1
answered on 11 Dec 2018, 06:46 AM
Hello, I have the same case with Ramya. I need to get the total of all max values  but I am using a standalone  Telerik designer. Is there a way to achieve this result? Thanks
0
Silviya
Telerik team
answered on 13 Dec 2018, 03:48 PM
Hello Argie,

TRDX reports need to be deserialized | unpackaged in a custom report resolver for the Reporting REST service to be able to modify them at run-time (add events).

Below code snippet demonstrates how to plug a custom resolver for the reports and to deserialize/modify TRDX report in it.
After having the type report instance, you can access it inner items(specific TextBox) with ItemCollection.Find Method and attach the event to it.
//Reporting REST Service
public class ReportsController : ReportsControllerBase
{
    static ReportServiceConfiguration configurationInstance;
  
    static ReportsController()
    {
        //This is the folder that contains the report definitions
        //In this case this is the Reports folder
        var appPath = HttpContext.Current.Server.MapPath("~/");
        var reportsPath = Path.Combine(appPath, "Reports");
          
        //Add resolver for trdx/trdp report definitions,
        //then add resolver for class report definitions as fallback resolver;
        //finally create the resolver and use it in the ReportServiceConfiguration instance.
        //var resolver = new ReportFileResolver(reportsPath)
        //    .AddFallbackResolver(new ReportTypeResolver());
        var resolver = new MyReportResolver();
  
        //Setup the ReportServiceConfiguration
        configurationInstance = new ReportServiceConfiguration
        {
            HostAppId = "Html5App",
            Storage = new FileStorage(),
            ReportResolver = resolver,
            // ReportSharingTimeout = 0,
            // ClientSessionTimeout = 15,
        };
    }
  
    public ReportsController()
    {
        //Initialize the service configuration
        this.ReportServiceConfiguration = configurationInstance;
    }
}
  
//Custom Resolver example
public class MyReportResolver : Telerik.Reporting.Services.Engine.IReportResolver
{
    public Telerik.Reporting.ReportSource Resolve(string report)
    {
        var testreport = new Telerik.Reporting.Report();
  
        System.Xml.XmlReaderSettings settings = new System.Xml.XmlReaderSettings();
        settings.IgnoreWhitespace = true;
  
        var appPath = HttpContext.Current.Server.MapPath("~/");
        var reportPath = Path.Combine(appPath, "Reports/Report1.trdx");
  
        using (System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create(reportPath, settings))
        {
            Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer = new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
            testreport = (Telerik.Reporting.Report)xmlSerializer.Deserialize(xmlReader);
        }
  
        Telerik.Reporting.TextBox textBox5 = testreport.Items.Find("textBox5", true)[0] as Telerik.Reporting.TextBox;
        textBox5.ItemDataBound += textBox5_ItemDataBound;
 
        Telerik.Reporting.TextBox textBox7 = testreport.Items.Find("textBox7", true)[0] as Telerik.Reporting.TextBox;
        textBox7.ItemDataBinding += textBox7_ItemDataBinding;
 
  
        var IRS = new InstanceReportSource();
        IRS.ReportDocument = testreport;
  
        return IRS;
    }
  
    private void textBox5_ItemDataBound(object sender, EventArgs e)
    {
            Telerik.Reporting.Processing.TextBox txt = (Telerik.Reporting.Processing.TextBox)sender;
            int value = Convert.ToInt32(txt.Value);
            sum += value;
    }
 
    private void textBox7_ItemDataBinding(object sender, EventArgs e)
    {
        Telerik.Reporting.Processing.TextBox txt = (Telerik.Reporting.Processing.TextBox)sender;
         txt.Value = sum.ToString();
    }
}

Regards,
Silviya
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Argie
Top achievements
Rank 1
answered on 17 Dec 2018, 01:44 AM
Thanks Silviya, I'll try this out!
Tags
General Discussions
Asked by
Xuan Truong
Top achievements
Rank 1
Answers by
Xuan Truong
Top achievements
Rank 1
Steve
Telerik team
Massimiliano Bassili
Top achievements
Rank 1
Squall
Top achievements
Rank 1
Kapil
Top achievements
Rank 1
Jitendra
Top achievements
Rank 1
Ramya
Top achievements
Rank 1
Katia
Telerik team
Ravi
Top achievements
Rank 1
vikas
Top achievements
Rank 1
Argie
Top achievements
Rank 1
Silviya
Telerik team
Share this question
or