如果 $C$5="Y",下面的公式返回至少 10 个值(如果包括对角线值)。如果 $C$5="Y",我们如何才能只获得非对角线值。
=VSTACK({"V1","V2","V3","V4"},
HSTACK({1;2;3;4;5;6;7;8;9;10},TAKE(SORT(--TEXTSPLIT(TEXTAFTER("|"&
TOCOL(IFS(ISNUMBER(ABS(IF(ISREF(IF($C$5="N",INDIRECT("'"&$C$10&"'!B2:E5"),IF(ROW(INDIRECT("'"&$C$10&"'!B2:E5"))=COLUMN(INDIRECT("'"&$C$10&"'!B2:E5")),0,INDIRECT("'"&$C$10&"'!B2:E5")))), IF($C$5="N",INDIRECT("'"&$C$10&"'!B2:E5"),IF(ROW(INDIRECT("'"&$C$10&"'!B2:E5"))=COLUMN(INDIRECT("'"&$C$10&"'!B2:E5")),0,INDIRECT("'"&$C$10&"'!B2:E5"))), 0)-
IF($C$5="N",INDIRECT("'"&$C$9&"'!B2:E5"),IF(ROW(INDIRECT("'"&$C$9&"'!B2:E5"))=COLUMN(INDIRECT("'"&$C$9&"'!B2:E5")),0,INDIRECT("'"&$C$9&"'!B2:E5"))))),ABS(IF(ISREF(IF($C$5="N",INDIRECT("'"&$C$10&"'!B2:E5"),IF(ROW(INDIRECT("'"&$C$10&"'!B2:E5"))=COLUMN(INDIRECT("'"&$C$10&"'!B2:E5")),0,INDIRECT("'"&$C$10&"'!B2:E5")))), IF($C$5="N",INDIRECT("'"&$C$10&"'!B2:E5"),IF(ROW(INDIRECT("'"&$C$10&"'!B2:E5"))=COLUMN(INDIRECT("'"&$C$10&"'!B2:E5")),0,INDIRECT("'"&$C$10&"'!B2:E5"))), 0)-IF($C$5="N",INDIRECT("'"&$C$9&"'!B2:E5"),IF(ROW(INDIRECT("'"&$C$9&"'!B2:E5"))=COLUMN(INDIRECT("'"&$C$9&"'!B2:E5")),0,INDIRECT("'"&$C$9&"'!B2:E5"))))&"|"&INDIRECT("'"&$C$9&"'!A2:A5")&"|"&INDIRECT("'"&$C$9&"'!B1:E1")),3),"|",{1,2,3}),"|"),,1),10)))
第2页
1 | 2 | 3 | 4 | 5 | |
---|---|---|---|---|---|
1 | 83 | 37 | 69 | 80 | 52 |
2 | 89 | 44 | 30 | 64 | 47 |
3 | 56 | 39 | 87 | 88 | 92 |
4 | 60 | 38 | 34 | 35 | 93 |
5 | 21 | 75 | 66 | 47 | 79 |
第3页
1 | 2 | 3 | 4 | 5 | |
---|---|---|---|---|---|
1 | 43 | 22 | 46 | 2 | 27 |
2 | 5 | 21 | 37 | 1 | 37 |
3 | 11 | 18 | 6 | 32 | 2 |
4 | 42 | 10 | 10 | 36 | 46 |
5 | 9 | 22 | 1 | 41 | 37 |
结果输出:
所需输出:
前四行是对角线值,不应该出现在那里,该表应从第 5 行开始。
=LET(r_adress,"B2:E5",sample,10,s_ref1,C9,s_ref2,C10,yes_no,C5,
data1,INDIRECT("'"&s_ref1&"'!"&r_adress),
data2,INDIRECT("'"&s_ref2&"'!"&r_adress),
rc,ROWS(data1),trc,rc^2,s,SEQUENCE(trc),
h,"V"&SEQUENCE(,rc),
rs,ROUNDUP(s/rc,),
cs,MOD(s-1,rc)+1,
d,TOCOL(ABS(data1-data2)),
st,TAKE(SORT(HSTACK(d,rs,cs)),sample),
f,IF(yes_no="y",FILTER(st,INDEX(st,,2)<>INDEX(st,,3)),st),
VSTACK(h,HSTACK(SEQUENCE(ROWS(f)),f)))