[英]How do you flag cells by comparing values in another column with the same 'ID' column?
I have a sample table like this:我有一个这样的示例表:
base根据
I wanted to flag if there is an increase in Output of the same ID compared to the previous Date.我想标记相同 ID 的 Output 与上一个日期相比是否有所增加。 Note that the data is only sorted by Date .请注意,数据仅按日期排序。
Expected output: output预计 output: output
I've been trying to find the correct formula so that it only compares between current output with previous output of the same ID in previous date with INDEX-MATCH functions and had no luck.我一直在尝试找到正确的公式,以便它只比较当前 output 与之前日期相同 ID 的 output与 INDEX-MATCH 函数之间的比较,但没有运气。 Thank you for your assistance.谢谢您的帮助。
=IF(AND(D2>INDEX($D$2:$D$9, MATCH(C2,$C$2:$C$9,0)-1), C2=INDEX($C$2:$C$9, MATCH(B2,$B$2:$B$9,0)-1)), "Flag", "")
The following is an array approach.以下是数组方法。 In cell D2
use the following formula:在单元格D2
中使用以下公式:
=LET(A, A2:A9, B, B2:B9, C, C2:C9, MAP(A, B,C, LAMBDA(aa,bb,cc, LET(
f, FILTER(C, (B=bb) * (A < aa),""), IF(OR(@f="", TAKE(f,-1)>=cc),"", "Flag")))))
On each MAP
iteration we filter Output column ( C
) by ID ( B
) equals to bb
and only previous dates.在每次MAP
迭代中,我们通过等于bb
的ID ( B
) 过滤Output列 ( C
) 并且仅过滤之前的日期。 To select filtered the output ( f
) that corresponds to previous date we use: TAKE(f,-1)
, ie select the last filtered row (data is sorted by date in ascending order).对于 select 过滤了对应于上一个日期的 output ( f
) 我们使用: TAKE(f,-1)
,即 select 最后过滤的行(数据按日期升序排列)。 Then we check for empty condition: the filter result is empty ( @f=""
), ie no result returned under filter condition or the output is not ascending.然后我们检查空条件:过滤结果为空( @f=""
),即过滤条件下没有返回结果或者output没有升序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.