How to Filter on Data Grid and Apply the Results to Variables

Zane Winberg shared this question 5 years ago
Answered

I have a data grid called RepairItems. I am selecting the RepairItem_ID's using this statement: Select[RepairItems, RepairItem_ID]


It returns 6002,6003,6005 for this example. My user deleted rows 6001 and 6004 from the data grid during simulation and that is why it is returning 6002,6003 and 6005.


What I want to do now is take each of these remaining rows (RepairItem_ID's) and apply them to a new variable which contains the row's contents for each for further manipulation. For example:


Put the row contents from 6002 on varRow1


Put the row contents from 6003 on varRow2


Put the row contents from 6005 on varRow3


I am not sure how to write an expression to do set the value for each varRow.

Comments (4)

photo
1

Take a look at this tutorial:http://www.justinmind.com/prototyper/...


In the tutorial only one row is stored in the variable, but a variable can hold also many rows.

photo
1

Hi Victor,


Thanks for the response... revisiting this issue again today. Unfortunately, from your video suggested, I don't see how to simply use a string function to parse a variable that holds these values (6002,6003,6005) and put each into its own variable (example: varRow1, varRow2, and varRow3) for further use in my prototype.


I don't really have a row_1 type of scenario to use as an attribute for filtering out what is in the variable as a string value (6002,6003,6005). So I'm just looking for a way to parse the variables values, separated by commas for further use as described.


Do you have any suggestions for me? Maybe I missed something.


Thanks again...

photo
1

Hi Zane,


Sorry I didn't understand you before. What you need to do is to use the 'substring' function to split the value in the variable in three. I made a prototype for you http://d2ld3he4yll0xl.cloudfront.net/...


Also, you can learn more about how to use the substring function in this two tutorials:


http://www.justinmind.com/usernote/te...


http://www.justinmind.com/usernote/te...

photo
1

Thank you Victor! Works like a charm. I didn't understand the Index function well enough and this helped a bunch.