Excel Return Array if condition is true

泄露秘密 提交于 2021-01-29 17:16:48

问题


I am trying to get something of the effect that when I have an if statement: if({TRUE;FALSE;TRUE},{1,2,3}) it will return with {1,3} is there any way to get this effect with an array of conditions and return an array of results?


回答1:


If one has the Dynamic Array Formula FILTER:

=FILTER({1,2,3},TRANSPOSE({TRUE;FALSE;TRUE}))

Without dynamic Array formula:

=TRANSPOSE(MODE.MULT(IF({TRUE;FALSE;TRUE},ROW(1:3)*{1,1})))

This is an array formula and depending on ones version, it may need to be confirmed with Ctrl-Shift-Enter when exiting edit mode.




回答2:


This formula will do what you say you want.

Note that there are a bunch of TRANSPOSE functions. This is because your Booleans are semicolon separated and your condition_if_true result is comma separated.

 =TRANSPOSE(AGGREGATE(15,6,IF(1/{TRUE;FALSE;TRUE},TRANSPOSE({1,2,3})),ROW(INDIRECT("1:"& SUM(--{TRUE,FALSE,TRUE})))))



来源:https://stackoverflow.com/questions/60456891/excel-return-array-if-condition-is-true

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!