# All Possible Permutation of a data set order

I have three arrays represented as Body Part, Left and Right, Position standing or sitting.  The array looks like this:
Knee      Standing      Left
Ankle      Sitting      Right
Foot
Leg
Hand
Elbow
Arm

Body Parts Arm, Hand and Elbow can only have sitting position. Here are all 22 possible combination pairs.  We get this because Arm, Hand and Elbow can only have sitting position:
Knee      Left      Standing
Knee      Left      Sitting
Knee      Right       Standing
Knee      Right       Sitting
Ankle      Left      Standing
Ankle      Left      Sitting
Ankle      Right       Standing
Ankle      Right       Sitting
Foot      Left      Standing
Foot      Left      Sitting
Foot      Right       Standing
Foot      Right       Sitting
Hand      Left      Sitting
Hand      Right       Sitting
Elbow      Left      Sitting
Elbow      Right       Sitting
Arm      Left      Sitting
Arm      Right       Sitting
Leg      Left      Standing
Leg      Left      Sitting
Leg      Right       Standing
Leg      Right       Sitting

I need a permutation with all possible orders.  Here is an output example:

Patient      BodyPart      Laterality      Position
A      Knee      Left      Standing
A      Knee      Right       Standing
B      Foot      Left      Standing
B      Hand      Left      Sitting
C      Elbow      Right       Sitting
D      Elbow      Right       Sitting
E      Arm      Left      Sitting
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
You can make 2 tables; one with body part and possible position and a second for laterality. Place those two tables into a query. Because they're not joined, you will get one record each body part, position and laterality. If you make another table for patients and then place that in a query with the first query, you'll have all possible combinations for each patient. See attached.

Flyster
Permutation.accdb
0
Software DeveloperAuthor Commented:
Hello Flyster,

Thank you very much for helping!

Is it possible to make all possible orders of the Permutation results below because the patient are not coming in having the same body parts examed in a row and then next, such as all Knees, all foot and all Arms.  The patients could come in any order.  Please see the example at the bottom.  I think I need all possible orders of the perpermutation results and randomize them.

BodyPart      Position      Laterality
Knee      Standing      Left
Knee      Standing      Right
Knee      Sitting      Left
Knee      Sitting      Right
Ankle      Standing      Left
Ankle      Standing      Right
Ankle      Sitting      Left
Ankle      Sitting      Right
Foot      Standing      Left
Foot      Standing      Right
Foot      Sitting      Left
Foot      Sitting      Right
Leg      Standing      Left
Leg      Standing      Right
Leg      Sitting      Left
Leg      Sitting      Right
Hand      Sitting      Left
Hand      Sitting      Right
Elbow      Sitting      Left
Elbow      Sitting      Right
Arm      Sitting      Left
Arm      Sitting      Right

Patient      BodyPart      Position      Laterality
1      Knee      Standing      Left
2      Knee      Standing      Right
3      Ankle      Standing      Left
4      Ankle      Standing      Right
5      Knee      Standing      Left
5      Knee      Standing      Right
6      Foot      Standing      Left
7      Leg      Standing      Left
8      Knee      Standing      Left
10      Arm      Sitting      Left
0
Commented:
You can do that in two tables. The first table lists all the permutations with an ID assigned to each one. The second table lists the patients with the associated permutation ID. Put both tables in a query and link the ID's.  See attached.
Permutation.accdb
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Software DeveloperAuthor Commented: