在Google Spreadsheet中将对角线转置为行? [英] Transpose Diagonal to row in Google Spreadsheet?

查看:150
本文介绍了在Google Spreadsheet中将对角线转置为行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到一个公式,它会返回数组A1,D4的对角线,如下所示:
A1 B2 C3 d4



我发现这一个,它返回一个列,但我不知道如何排序在一行中的值。


$ b

= INDEX(A1:D1,,ROWS($ 1:1))

下面)

结果上的TRANSPOSE当然可以做到这一点,但我会欣赏稍微优雅的东西。谢谢!

解决方案

如果您使用您提到的确切范围(A1:D4)
$ b

  = ARRAYFORMULA(TRIM(QUERY(IF(ROW(A1:D4)= COLUMN(A1:D4),A1:D4))ROWS A1:A4))))

(无需填写。)





如果要获取任何范围的对角线值(此处为:B11 :E14),尝试

  = ARRAYFORMULA(TRIM(QUERY(IF(ROW(B11:E14)-ROW(B11)+ 1 = COLUMN(B11:E11)-COLUMN(B11)+1,B11:E14),ROWS(B11:B14))))


I've tried to find a formula that would return the diagonal of an array A1:D4 as follows: A1 B2 C3 D4

I found this one, which returns a column, but I can't find out how to order the values in a row instead.

=INDEX(A1:D1,,ROWS($1:1))

(paste in the columns below)

A TRANSPOSE on the result would of course do the trick, but I'd appreciate something slightly more elegant. Thanks!

解决方案

If you use the exact range you mentioned (A1:D4) then this should work

=ARRAYFORMULA(TRIM(QUERY(IF(ROW(A1:D4)=COLUMN(A1:D4), A1:D4,),,ROWS(A1:A4))))

(No need to fill down.)

If you want to get the diagonal values of any range (here: B11:E14), try

=ARRAYFORMULA(TRIM(QUERY(IF(ROW(B11:E14)-ROW(B11)+1=COLUMN(B11:E11)-COLUMN(B11)+1, B11:E14,),,ROWS(B11:B14))))

这篇关于在Google Spreadsheet中将对角线转置为行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆