The BARCOUNT function counts the total number of daily values in a dataset, so it will always use the last value, and not the day-by-day count. BARINDEX() gives a running count but not when used in a bar variable situation, so I can’t think of a way that this can be done.