michaeltsmith93
Board Regular
- Joined
- Sep 29, 2016
- Messages
- 83
Table 1 features my source data, and I'm looping through it and counting the total # of X and Z visits. That output looks like Table 2. What you'll notice is that since I'm looping through by rows, Ringo's visit (13-May) is counted first, increasing the counter by 1 and therefore putting a 1 in my Count Z column. Unfortunately, Paul's visit is noticed by the loop after Ringo's, but it is the second visit that the counter has seen, so it is counted as the second visit despite the fact that Paul's visit obviously took place first. This becomes problematic because my line graph of table 2 has the count go down between 11-May (where the count is 2) and 13-May (where the count is 1).
Any thoughts on the fastest way to redistribute the counts? I can't switch the dates, but I can swap the counts themselves (i.e., the 2 and the 1 in the Count Z row could be swapped with no issue since Excel will properly order the data points on the chart). Speed is paramount because this chart update is part of a presentation-style sheet in which groups of patients are discussed, and I'm already loading a ton of other data, so the run-time is a good 2-3 seconds.
Edit: Can I do a bubble sort of a 2d array such that I'm sorting the dates and the counts get moved around? What would that look like?
Table 1
Table 2
Any thoughts on the fastest way to redistribute the counts? I can't switch the dates, but I can swap the counts themselves (i.e., the 2 and the 1 in the Count Z row could be swapped with no issue since Excel will properly order the data points on the chart). Speed is paramount because this chart update is part of a presentation-style sheet in which groups of patients are discussed, and I'm already loading a ton of other data, so the run-time is a good 2-3 seconds.
Edit: Can I do a bubble sort of a 2d array such that I'm sorting the dates and the counts get moved around? What would that look like?
Table 1
Patient | X Visit Date | Z Visit Date |
John | 10-May | |
Ringo | 13-May | |
George | 12-May | |
Paul | 11-May | |
Eric | 14-May |
Date | 10-May | 13-May | 12-May | 11-May | 14-May |
Count X | 1 | 2 | |||
Count Z | 1 | 2 | 3 |