Hello,
I have a one column ("BIN") with a bunch of different character values and each row in the dataset refers to a unique unit that was tested. Without having to transform/summarize the dataset I would like to create a column formula that prompts the user with a ListBox dialog with a set of all the unique values within the "BIN" column. After selecting the desired values in the ListBox, the units that have a value within the "BIN" column will have a value of 1 set for the generated column ("BIN_DISPOSITION"), and the columns that units that do not have a "BIN" value that matches the ListBox selection will have a value of 0 set to the generated column ("BIN_DISPOSITION").
Example:
In the case that the user runs the formula column and selects "BIN2" and "BIN3", the following output is desired.
Unit#
| BIN | BIN_DISPOSITION (generated by Column Formula) |
|---|
Unit1 | BIN1 | 0 |
| Unit2 | BIN2 | 1 |
| Unit3 | BIN2 | 1 |
| Unit4 | BIN1 | 0 |
| Unit5 | BIN3 | 1 |
Script:
bin_values_all = {};
bin_values_all_sorted = {};
bin_values_selected = {};
If(Row() == 1,
For Each Row(If(!Contains(bin_values_all, :BIN[Row()]),
Insert Into(bin_values_all, :BIN[Row()])
);
bin_values_all_sorted = Sort Ascending(bin_values_all);
New Window("BIN Value Selection", Modal,
Outline Box("BIN Value Selection",
lb = List Box(
bin_values_all_sorted
),
Button Box("OK",
bin_values_selected = lb << GetSelected
);
If(Contains(bin_values_selected, :BIN),
1,
0
);
I had to add the conditional If(Row() == 1...) so that the dialog and list generation did not run more than once, but it seems that my variable declarations above this would be re-initialized each time, which is not what I want.
I wasn't quite sure if there was a built-in way to do this or not.
Wondering if anyone has any ideas.
Thanks,
JP