Hello Jarmo,
If I try to apply the solution to three columns, it works. However, I am not able to create a unique selection based on the first AND second columns.
Names Default To Here(1);
v1 = "";
v2 = "";
v3 = "";
dt = Open("JMP_Question.xlsx", Worksheets("Sheet1"), invisible);
Summarize(dt, uniqvals_1 = by(:Column 1));
Summarize(dt, uniqvals_2 = by(:Column 2));
Summarize(dt, uniqvals_3 = by(:Column 2,:Column 3));
aa_options = Associative Array();
For(i = 1, i <= N Items(uniqvals_1), i++,
col1_idx = dt << Get Rows Where(:Column 1 == uniqvals_1[i]);
col2_vals = dt[col1_idx, "Column 2"];
aa_options[uniqvals_1[i]] = col2_vals;
);
ab_options = Associative Array();
For(i = 1, i <= N Items(uniqvals_2), i++,
col2_idx = dt << Get Rows Where(:Column 2 == uniqvals_2[i]);
col3_vals = dt[col2_idx, "Column 3"];
ab_options[uniqvals_2[i]] = col3_vals;
);
/*
ac_options = Associative Array();
For(i = 1, i <= N Items(uniqvals_1), i++,
col1_idx = dt << Get Rows Where(:Column 1 == uniqvals_1[i]);
col2_vals = dt[col1_idx, "Column 2"];
For(j=1, j<=N Items(uniqvals_2),j++
col2_idx = dt << Get Rows Where(:Column 2 == uniqvals_2[j]);
col3_vals = dt[col2_idx, "Column 3"];
ac_options[uniqvals_2[j]] = col3_vals;
);
);
*/
print(ac_options);
nw = New Window("Set the Value",
Lineup Box(N Col(2),
Text Box("Col1"),
cb1 = Combo Box(uniqvals_1, << set function(function({this},
cb2_vals = aa_options[(this << get selected)];
cb2 << Set Items(cb2_vals);
)), << Set(1)
),
Text Box("Col2"),
cb2 = Combo Box(uniqvals_2, << set function(function({this},
cb3_vals = ab_options[(this << get selected)];
cb3 << Set Items(cb3_vals);
)), << Set(1)
),
Text Box("Col3"),
cb3 = Combo Box(ab_options[uniqvals_2[1]])
),
H List Box(
Button Box("OK",
v1 = cb1 << get selected;
v2 = cb2 << get selected;
v3 = cb3 << get selected;
nw << close window;
show(v1, v2, v3);
),
Button Box("Cancel", nw << close window)
)
);
The above code works. However, if you look at the attached images, I am not able to create unique lists for Col2 and Col3.
There is probably a straightforward solution that I am missing.
Thanks!