Ask Your Question
2

How can a column be created to display the count of unique values that differ between two consecutive days?

asked 2021-10-23 11:00:00 +0000

devzero gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-11-19 06:00:00 +0000

plato gravatar image

Assuming that the data is sorted by date and that the unique values are in column A, you can use the following formula to calculate the count of unique values that differ between two consecutive days:

=SUM(--(FREQUENCY(IF(A2:A1000<>A1:A999,ROW(A2:A1000)),IF(A2:A1000<>A1:A999,ROW(A1:A999)))>0))

This is an array formula, so it must be entered with Ctrl+Shift+Enter, not just Enter.

Explanation of the formula:

  1. The IF function checks whether the values in column A of the current row and the previous row are different (i.e., whether there has been a change in the unique values).

  2. The ROW function returns the row numbers of the corresponding cells.

  3. The FREQUENCY function calculates how many times each row number appears in the two arrays.

  4. The >0 operator returns an array of TRUE and FALSE values indicating whether each row number appears at least once in the two arrays.

  5. The double negative (--) converts the TRUE and FALSE values to 1s and 0s.

  6. The SUM function adds up the 1s, which gives the count of unique values that differ between two consecutive days.

Note that the range A2:A1000 and A1:A999 should be adjusted to cover all the cells with data in your worksheet.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-10-23 11:00:00 +0000

Seen: 12 times

Last updated: Nov 19 '21