need Aggregate function that uses sum of other aggregate functions

4 posts, 0 answers
  1. Brian Graves
    Brian Graves avatar
    48 posts
    Member since:
    May 2010

    Posted 29 May 2010 Link to this post

    I have several columns that need aggregates functions using the aggregate results of 2 other columns.  For instance, column 1's aggregate function needs to take the sum of column 2 and divide it by the sum of column 3.  Columns 2 and 3 use the SumFunction...example:
    var sumFunction = new SumFunction();
    sumFunction.FunctionName = "SumColumn2";
    sumFunction.SourceField = "Column2";
    col.AggregateFunctions.Add(sumFunction); they are calculated when binding occurs.  Therefore, I have to calculate column 1 and put it in my footer AFTER I set my ItemsSource in the datagrid:
    _dg.ItemsSource = datalist;
    object value = (Convert.ToDouble(_dg.AggregateResults["SumColumn2"].Value) / Convert.ToDouble(_dg.AggregateResults["SumColumn3"].Value)) * 100;
    _dg.Columns["Column1"].Footer = String.Format("{0:F2}", value);

    This is fine for showing my footer summary.  However, my group aggregate footer column is blank since it is part of my GridViewGroupRow...not my Footer.  Basically, I can't use this approach anymore since columns 2 and 3 show up fine for my group aggregate footer I'm assuming for column 1 that I need to create my own custom aggregate function.  However, how can I get my custom aggregate function to look at _dg.AggregateResults if they aren't calculated yet?  Please let me know the proper way of handling this issue.  Thanks in advance.  :)
  2. Veselin Vasilev
    Veselin Vasilev avatar
    2992 posts

    Posted 02 Jun 2010 Link to this post

    Hello Brian Graves,

    Can you please check the solutions in this forum thread:
    how can I mimic Excel's SUMPRODUCT for my footer?

    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft R3 2016 release webinar banner
  4. Arun
    Arun avatar
    4 posts
    Member since:
    Jul 2010

    Posted 18 Aug 2010 Link to this post

    HI Veskoni,

    I am facing the exact same issue as Brian.

    In my case, I have revenue and usage information in column A and B respectively, and I am trying to find rate( in column C)=revenue/usage. 
    I am able to get  the group footer sum value for A and B column, but I cannot figure out a way to find the average "rate" in column C's group footer, which would be equal to total revenue/total usage.
    I tried using the solution you suggested( I cannot implement it because of the constraint I have with my business object.

    I found this code snippet which would work for ASP for setting the group footer with calculated value programatically, but I cannot figure out the equivalent for silverlight RadGridView
    grd_ItemDataBound(object sender,GridItemEventArgs e)
        //catch the footer element
          { (e.Item.FindControl("yourTextBox") as TextBox).Text = your calculated value }
    I can calculate the average rate by using total revenue and total rate by accessing the group footers for revenue and usage columns. It would be great if you could provide me the silverlight equivalent for the above snippet.

    Thanks in advance,

    Arun Nair
  5. Kevin Tran
    Kevin Tran avatar
    40 posts
    Member since:
    Apr 2010

    Posted 16 Sep 2010 Link to this post

     did you solved this issue , i too struck with the same

Back to Top