[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 289
  • Last Modified:

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
0
Charles Baldo
Asked:
Charles Baldo
  • 2
  • 2
1 Solution
 
FlysterCommented:
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
 
Charles BaldoSoftware 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
 
FlysterCommented:
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
 
Charles BaldoSoftware DeveloperAuthor Commented:
Thank You was helpful
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now