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

  • Home
  • SEARCH
  • 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 6120565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:40:58+00:00 2026-05-23T15:40:58+00:00

I have an EnumerableRowCollection that looks like the following: VendorCode | GroupType | Variance

  • 0

I have an EnumerableRowCollection that looks like the following:

VendorCode | GroupType | Variance
    01165       G          .16
    01165       G          .16

    01165       CH         .16
    01165       CH         .18

    07754       G          .25
    07754       G          .25
    07754       G          .39

Essentially, this is a massive list of vendor codes, their groups, and price variances. I need to compose a query that will create a distinct list vendor codes and group types. The catch, however, is that I need to evaluate all of the variances associated with that particular VendorCode/GroupType to see if they are all the same – it they are not, I need to return some way of signifying that the group has a “custom” variance, otherwise it needs to return the value (ie: if they are all .16, then return .16, if there are multiple values, return “custom”)

The result would look like this, based off of the list I showed above.

VendorCode | GroupType | Variance
   01165        G          .16
   01165        CH         custom
   07754        G          custom

I have no trouble getting a distinct list of VendorCode/GroupType – this is what I have so far:

Dim distinctList = From q In query Select q.VendorCode, q.GroupType, (evaluated q.Variance here?) Distinct

(where “query” is an EnumerableRowCollection(Of (anonymous type)))

I’m at a loss, though, on how to evaluate the variance property to get the result that I need – any ideas?

  • 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-23T15:40:58+00:00Added an answer on May 23, 2026 at 3:40 pm

    I can’t do the VB, but in C# I think you’d want something like:

    var query = from item in source
                group item by new { item.VendorCode, item.GroupType } into g
                select new { g.Key.VendorCode,
                             g.Key.GroupType,
                             Variance = ComputeVariance(g) };
    
    ...
    
    string ComputeVariance(IEnumerable<YourItemType> group)
    {
        var distinctVariance = group.Select(x => x.Variance)
                                    .Distinct();
        using (var iterator = distinctVariance.GetEnumerator())
        {
            iterator.MoveNext(); // Assume this will return true...
            var first = iterator.Current;
            return iterator.MoveNext() ? "custom" : first.ToString();
        }
    }
    

    That’s assuming you’re using LINQ to Objects. If you need to do this in LINQ to SQL etc, I’d take a slightly different approach.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a Facebook app that is failing as of this morning with the following
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
Have the following code: $(#blogs).mouseover( function () { $(this).addClass(hover); $(#home).removeClass(hover); $(#homepages).removeClass(hover); $(#apps).removeClass(hover); $(#facebook).removeClass(hover); $(#kontakt).removeClass(hover);
I have a Generic list of a class that I automatically convert it to
Have a recurring situation, petty I know, but I'd like to consolidate the following:
have written this little class, which generates a UUID every time an object of
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
Importing a spreadsheet I have filled a DataTable object with that data and returns
Have a chat room, issue is, is that when you submit something, the message
Have been trying to figure this problem out for a while now and was

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.