Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4337776
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:59:26+00:00 2026-05-21T10:59:26+00:00

I have some data in a List of User defined types that contains the

  • 0

I have some data in a List of User defined types that contains the following data:

name, study, group, result, date. Now I want to obtain the name, study and group and then a calculation based onthe result and date. The calculation is effectively:

log(result).where max(date) minus log(result).where min(date)

There are only two dates for each name/study/group, so the result from the maximum data (log) minus the result from the minumum date (log). here is what I have tried so far with no luck:

 var result = 
    from results in sortedData.AsEnumerable()
    group results by results.animal
    into grp
    select new
    {
         animal = results.animal,
         study = results.study,
         groupNumber = results.groupNumber,
         TGI = System.Math.Log(grp.Select(c => c.volume)
                                  .Where(grp.Max(c=>c.operationDate)))
             - System.Math.Log(grp.Select(c => c.volume)
                                  .Where(grp.Min(c => c.operationDate)))
    };

Anybody any pointers? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T10:59:27+00:00Added an answer on May 21, 2026 at 10:59 am

    It isn’t entirely clear how the grouping relates to your problem (what sense does it make to extract a property from a range variable after it has been grouped?), but the part you’re having difficult with can be solved easily with MaxBy and MinBy operators, such as the ones that come with morelinq.

    var result = from results in sortedData.AsEnumerable()
                 group results by results.animal into grp
                 select new
                 {
                    animal = grp.Key,
                    study = ??,
                    groupNumber = ??,
                    TGI  =  Math.Log(grp.MaxBy(c => c.operationDate).volume) 
                          - Math.Log(grp.MinBy(c => c.operationDate).volume)    
                  };
    

    Otherwise, you can simulate these operators with Aggregate, or if you don’t mind the inefficiency of sorting:

    var result = from results in sortedData.AsEnumerable()
                 group results by results.animal into grp
    
                 let sortedGrp = grp.OrderBy(c => c.operationDate)
                                    .ToList()
                 select new
                 {
                    animal = grp.Key,
                    study = ??,
                    groupNumber = ??,
                    TGI  = sortedGrp.Last().volume  - sortedGrp.First().volume               
                 };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some financial data gathered at a List[(Int, Double)], like this: val snp
I have some C structures related to a 'list' data structure. They look like
Say you have a simple class with some storage data structure (list, vector, queue,
I have a list of states, each with some data associated with it, displayed
I have some data for my sites statistics in a SQL DB: date: visits:
I have some data: transaction <- c(1,2,3); date <- c(2010-01-31,2010-02-28,2010-03-31); type <- c(debit, debit,
I have some data structures that stay unchanged if you try to add something
I have some javascript/jquery code that dynamically populates an unordered list with a bunch
I'm currently working on an app using MVVM that needs to have some data
I have a set of custom data types that can be used to manipulate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.