Forum Discussion
Reverse engineer data sheets from excel spreadsheet with summary percentages.
Here is the summary page:
| Yes | Refused | Not offered | Red | Yellow | Blue | ||
| Code | Question | ||||||
| G1a | Did the dog eat his food? | 98% | 1% | 1% | |||
| G2a | What color is the ball? | 95% | 1% | 4% | |||
| G2b | What color is the dress? | 28% | 34% | 38% |
I need to make 100 sheets of this same page, but have the computer enter the answers, like this:
| 5/30/2023 | Yes | Refused | Not offered | Red | Yellow | Blue | |
| Code | Question | ||||||
| G1a | Did the dog eat his food? | x | |||||
| G2a | What color is the ball? | x | |||||
| G2b | What color is the dress? | x |
- mtarlerMay 31, 2023Silver Contributor
Janine_Dismukes OK I think this may work for you. In the attached I have this formula:
=LET(in,Sheet1!$C2:$I2, totalnum, TotalN, nthVal, $L$1, cumulative,SCAN(0,totalnum*in,LAMBDA(p,q,p+q)), rseq,SORTBY(SEQUENCE(totalnum),PRNG(SEQUENCE(totalnum,,seed+10*ROW(),seed))), nth, XMATCH(nthVal,rseq), col, XMATCH(nth,INT(cumulative),1,1), rowout, TEXTSPLIT(MID(REPT(".",col)&col&REPT(".",COLUMNS(in)-col+1),2,COLUMNS(in)),".",,FALSE), rowout)It uses a custom pseudoRandom number generator I created to create a random sequence based on a seed. You can change the seed on Sheet1 in the attached ("seed" is named cell Sheet1!$L$1 in this case) and that "seed" is then offset by 10*ROW() so each row will have a different random sequence. Each sheet will have its own 'index' into that random sequence based on cell $L$1 which has the formula =Sheet()-1 in sheets 3&4 of this example but in sheet 2 I demonstrate how you can type any number in the range to see that result (i.e. you only need Sheet2 and you can change the value in $L$1 to see/simulate any of the 100 outputs (or whatever total value you enter in Sheet1!$L$2)
I have not tested every edge condition and combination but it seems to be working pretty well.