Luu Khanh Minh Posted November 21, 2018 Share Posted November 21, 2018 Is there any way to return the row number of a row or rows found by a Search add-on process? This is because I would like to use this number for other purposes in my model. Thanks! Link to comment Share on other sites More sharing options...
CWatson Posted November 21, 2018 Share Posted November 21, 2018 The Save Index Found property of the Search step (under Advanced Options) will store the row number that is found. ** IMPORTANT NOTE ** - this will relate to the actual row number in the table if it is not a relational table. For relational table rows, this value will return the row within the relation only. Link to comment Share on other sites More sharing options...
Luu Khanh Minh Posted November 22, 2018 Author Share Posted November 22, 2018 Hi Watson, my table is in fact a relational table. May I have some clarification on what you meant by the row within the relation? For example, if my table is like this: Brand Quantity P&G 100 Vendor1 20 Vendor2 30 Vendor3 50 And I would like to search the row with Vendor 2 30. Then may I ask which row number will be returned in this case? Thank you Link to comment Share on other sites More sharing options...
Luu Khanh Minh Posted November 22, 2018 Author Share Posted November 22, 2018 Hi Watson Thank you for your detailed answer. I still have another question about searching rows in a table, especially relational data table. In the search step, there is only 1 match condition. How can I search a row based on 2 or more conditions? Can I still use Search Row? Or must I use something else? Thank you! Link to comment Share on other sites More sharing options...
gocken Posted November 22, 2018 Share Posted November 22, 2018 (edited) 1) You can find what the save index value means by trial and error. Assign this value to a state variable and place a breakpoint onto the search step. Then, when simulation stops at that breakpoint check the state variable's value. 2) you can use match conditons sequential by using "&&" and "||" mathematical operators. For example, a) match condition with "&&": candidate.modelentity.color="red"&& candidate.modelentity.timecreated<500. The search step will found a modelentity when the expression written for match condition evaluated to "true". Fot match condition to be "true" both conditions have to be "true" (the value of candidate.modelentity.color="red" must equal to 1 and the value of candidate.modelentity.timecreated<500 must equal to 1). If not then the match condition will be "false". The search step can not found any modelentity. b) match condition with "||": candidate.modelentity.color="red"|| candidate.modelentity.timecreated<500. The search step will found a modelentity when the expression written for match condition evaluated to "true". Fot match condition to be "true" one of the conditions have to be "true" (the value of candidate.modelentity.color="red" must equal to 1 OR the value of candidate.modelentity.timecreated<500 must equal to 1). If not then the match condition will be "false". The search step can not found any modelentity. Edited November 22, 2018 by gocken 1 Link to comment Share on other sites More sharing options...
Recommended Posts