我有一个类似这样的电子表格,
Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday, Monday, Tuesday, ...
13-Nov-2022, 14-Nov-2022, 15-Nov-2022, 16-Nov-2022, 17-Nov-2022, ...
1:00, 2:05, 0:30, 2:00, 1:00, 0:05, 0:10, 1:20, 0:14
我想找出最大和的那一天,就是这里,星期日是2:20,所以我想在一个专栏里提到星期日。目前,我做了这样的事情,
MAX(SUMIFS(range_of_time_spent, range_of_days, a_particular_day),
SUMIFS(range_of_time_spent, range_of_days, a_particular_day),
...) # seven SUMIFS inside MAX for 7 different days
但这是2点20不是那天
2条答案
按热度按时间ou6hu8tu1#
用途:
对于旧版本,退出编辑模式时可能需要使用Ctrl-Shift-Enter而不是Enter。
jyztefdp2#
You can try this approach that uses
MMULT
. In cellA6
put the following formula:Notes:
MMULT
requires as input arguments arrays, it means you can use either ranges or arrays, so it gives more flexibility in case you are forced to use arrays. Let's say instead of calculating the totals ofA3:O3
, you need to perform an operation first in the range, for example:LOG10(A3:O3)
(now it is not a range but an array) or any other operation. In this case you cannot use any of the RACON excel functions , because they work only with ranges.TEXT
function. Great trick1
represents the day:1/1/1900
that was a Sunday and so on until:7
, i.e.1/7/1900
that was a Saturday.and here is the output:
Since you requested a solution for an older version, the above formula is more verbose. Let's use
LET
function ( Excel 2021 version ) to avoid repetition of the same calculation defining names. It also facilitates the comprehension of the formula (You can use named ranges for some of the range too)The main idea is to generate the
matrix
so we can perform the calculation in the way we want it. Let's try to understand the following expression first:If
a
is an1xm
array andb
annx1
andc
has the same shape asa
. It returns annxm
array, where on each row is compared the corresponding element ofb
against the entire arraya
. if there is a match it returns the corresponding value ofc
, otherwise returns0
. Here is the mathematical representation for the elements of the resulting matrix:For example:
returns
If we do a matrix multiplication of the previous result:
MMULT(matrix, {1;1;1;1;1;1})
we obtain the totals per row and this is exactly what we want.Understanding the previous logic. We just need to build the same logic adapted to our specific data:
wkdays
has the weekdays in a row array (arrayb
from previous example)days
the list of days (only weekday portion) in a column array (arraya
)ones
is the unit row array with the same number of rows as columns hasdays
.times
The times, the information we want to calculate the totals (arrayc
)matrix
generates a matrix using the logic explained before, but applied to our case:IF(days=wkdays, times,0)
totals
is the matrix multiplication:MMULT(matrix, ones)
returns the total oftimes
perwkdays
.The rest is just to find the index position of the maximum of
totals
viaMATCH/XMATCH
and finally useINDEX
to find the corresponding weekday.