CustomAggregateFunction or formula

4 posts, 0 answers
  1. Dario
    Dario avatar
    61 posts
    Member since:
    Apr 2011

    Posted 05 Jul 2011 Link to this post

    Hi,
    I need to create formula that do this:
    CustomersVisited / MyCustomers

    In my collection I have: Date, Agent, CustomersVisited and MyCustomersCount. I would another value that I can aggregate it, but this value is formula CustomersVisited / MyCustomers.
    I would Sum(CustomersVisited / MyCustomers)

    Can I do this? And if yes, how can I?
  2. Nikolay
    Admin
    Nikolay avatar
    386 posts

    Posted 07 Jul 2011 Link to this post

    Hi Dario,

    Please, consider using a custom sampling function for this scenario. You can find information on how to create such functions in this help topic.

    Greetings,
    Nikolay
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. DevCraft banner
  4. Dario
    Dario avatar
    61 posts
    Member since:
    Apr 2011

    Posted 07 Jul 2011 Link to this post

    Thank you for support,
    but it's not clear one things, I read Custom Sampling but in that examples keep one property of my list.
    If I whant use two proprties of my list both in Statistics class (of example Custom Sampling)?
  5. Nikolay
    Admin
    Nikolay avatar
    386 posts

    Posted 11 Jul 2011 Link to this post

    Hello Dario,

    In case you only need to create another property as a ratio between two of the other properties, you can do this in the following manner :
    public class MyClass
        {
            public int MyCustomers { get; set; }
            public int CustomersVisited { get; set; }
            public double CustomProp 
            
                get
                {
                    return this.CustomersVisited / this.MyCustomers;        
                }
            }
            public DateTime Date { get; set; }
        }

    The CustomProp property would return the ratio between CustomersVisited and MyCustomers, which can then be mapped to the YValue and you can apply sum or another aggregate function :
    ...
    <telerik:RadChart.SeriesMappings>
                    <telerik:SeriesMapping>
                        <telerik:ItemMapping DataPointMember="YValue" FieldName="CustomProp" />
                        <telerik:ItemMapping DataPointMember="XCategory" FieldName="Date" />
                    </telerik:SeriesMapping>
    </telerik:RadChart.SeriesMappings>
    ...

    Hope this helps.

    Kind regards,
    Nikolay
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top