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 8460057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:30:06+00:00 2026-06-10T13:30:06+00:00

This is a pretty complicated question so be prepared! I want to generate some

  • 0

This is a pretty complicated question so be prepared! I want to generate some test data in excel for my EAV table. The columns I have are:

user_id, attribute, value

Each user_id will repeat for a random number of times between 1-4, and for each entry I want to pick a random attribute from a list, and then a random value which this can take on. Lastly I want the attributes for each id entry to be unique i.e. I do not want more than one entry with the same id and attribute. Below is an example of what I mean:

user_id attribute   value
100001  gender      male
100001  religion    jewish
100001  university  imperial
100002  gender      female
100002  course      physics

Possible values:

attribute   value
gender      male
            female
course      maths
            physics
            chemistry
university  imperial
            cambridge
            oxford
            ucl
religion    jewish
            hindu
            christian
            muslim

Sorry that the table above messed up. I don’t know how to paste into here while retaining the structure! Hopefully you can see what I’m talking about otherwise I can get a screenshot.

How can I do this? In the past I have generated random data using a random number generator and a VLOOKUP but this is a bit out of my league.

  • 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-06-10T13:30:07+00:00Added an answer on June 10, 2026 at 1:30 pm

    My approach is to create a table with all four attributes for each ID and then filter that table randomly to get between one and four filtered rows per ID. I assigned a random value to each attribute. The basic setup looks like this:

    randomized eav table with lookup table

    To the left is the randomized eav table and to the left is the lookup table used for the randomized values. Here’s the formulas. Enter them and copy down:

    Column A – Establishes a random number every four digits. This determines the attribute that must be selected:

    =IF(COUNTIF(C$2:C2,C2)=1,RANDBETWEEN(1,4),A1)
    

    Column B – Uses the formula in A to determine if row is included:

    =IF(COUNTIF(C$2:C2,C2)=A2,TRUE,RANDBETWEEN(0,1)=1)
    

    Column C – Creates the IDs, starting with 100,001:

    =(INT((ROW()-2)/4)+100000)+1
    

    Column D – Repeats the four attributes:

    =CHOOSE(MOD(ROW()-2,4)+1,"gender","course","university","religion")
    

    Column E – Finds the first occurence of the Column D attribute in the lookup table and selects a randomly offset value:

    =INDEX($H$2:$H$14,(MATCH(D2,$G$2:$G$14,0))+RANDBETWEEN(0,COUNTIF($G$2:$G$14,D2)-1))
    

    When you filter on the TRUEs in Column B you’ll get your list of one to four Attributes per ID. Disconcertingly, the filtering forces a recalculation, so the filtered list will no longer say TRUE for every cell in column B.

    If this was mine I’d automate it a little more, perhaps by putting the “magic number” 4 in it’s own cell (the count of attributes).

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

Sidebar

Related Questions

Okay, this one is pretty complicated... lets say I have an array called $data
I'm back with another (possibly) silly question. sorry. I have a pretty complicated query
I have a pretty complicated IIF expression in SSRS, in which I want to
I find this pretty confusing. When you want to rotate a view, it's going
I have written something like this pretty easily in C# ( string GetUrl(new {
This is pretty straight forward. EDIT: Updated question and added fourth echo. Here is
This is pretty interesting, this site runs a speed test and compares all of
This is pretty much the same problem i have, except with very different code:
This is pretty much a duplicate question but instead of using Castle Dynamic Proxy
Background Expanding upon this question. I have a collection of points (in a three

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.