11-08-2020 11:04 AM
Hello everyone,
I'm stuck here for weeks, I have no idea how to optimize my code, and there's no flexibility too.
There are 20 products I need to analyze, each product has different parameters.
And there are 40 values in every parameters, so there would be 40*39=1560 vales in my file.
I have to compare each value in two files("preset file" and "analyze file"), if all of the values of Product 1 in "analyze file" are ≥ those in "preset file", then show the product number in array and calculate the percentage.
The values in the files are ranged according to the order as the table below:
Product Number | Parameter Number | Value in Parameter |
Product 1 | Para 23 | 40 valus |
Para 45 | 40 valus | |
Product 2 | Para 37 | 40 valus |
Product 3 | Para 28 | 40 valus |
Product 4 | Para 36 | 40 valus |
Para 11 | 40 valus | |
Para 19 | 40 valus | |
Product 5 | Para 30 | 40 valus |
Product 6 | Para 31 | 40 valus |
Para 19 | 40 valus | |
Para 26 | 40 valus | |
Product 7 | Para 40 | 40 valus |
Product 8 | Para 15 | 40 valus |
Para 11 | 40 valus | |
Para 19 | 40 valus | |
Product 9 | Para 19 | 40 valus |
Para 16 | 40 valus | |
Para 13 | 40 valus | |
Product 10 | Para 18 | 40 valus |
Para 16 | 40 valus | |
Para 13 | 40 valus | |
Product 11 | Para 31 | 40 valus |
Para 23 | 40 valus | |
Product 12 | Para 29 | 40 valus |
Product 13 | Para 17 | 40 valus |
Para 16 | 40 valus | |
Para 14 | 40 valus | |
Product 14 | Para 18 | 40 valus |
Para 14 | 40 valus | |
Product 15 | Para 39 | 40 valus |
Product 16 | Para 27 | 40 valus |
Product 17 | Para 15 | 40 valus |
Para 13 | 40 valus | |
Product 18 | Para 16 | 40 valus |
Para 14 | 40 valus | |
Para 13 | 40 valus | |
Product 19 | Para 19 | 40 valus |
Para 17 | 40 valus | |
Product 20 | Para 41 | 40 valus |
My problem is if there's any efficient way to code, because the Values in Parameter will not always be 40, I need to analyze the 20, 60, 500 and 1000.
Any help would be greatly appreciated.
Solved! Go to Solution.
11-08-2020 03:58 PM
Does your current code produce the correct result from the given data?
11-08-2020 04:43 PM
See if this can give you some ideas (result is the same!)
(I am sure it can be further simplified. This is just a very quick attempt)
11-08-2020 05:11 PM - edited 11-08-2020 05:53 PM
@edwardmax101 wrote:
My problem is if there's any efficient way to code, because the Values in Parameter will not always be 40, I need to analyze the 20, 60, 500 and 1000.
Note that if the number can differ between runs (but is constant for any given dataset) just turn my "40" diagram constant (lower left of code) into a control and set it according to the requirements of the set to be analyzed.
My code also assumes that the number of array elements is divisible by this number, but you can always add verification if desired.