简体   繁体   English

1 个单元格中的每日平均利润公式

[英]Average profit per day formula in 1 single cell

I want to use the solution explained here:我想使用这里解释的解决方案:

How to calculate an average profit per day with Google Sheets 如何使用 Google 表格计算每天的平均利润

But in just a single cell instead of having to use 4 different cells for the calculation.但只需一个单元格,而不必使用 4 个不同的单元格进行计算。

I came up with this formula but it seems to me too complicated and inefficient:我想出了这个公式,但在我看来它太复杂且效率低下:

=AVERAGEIF((arrayformula(if((arrayformula(if(query({A2:A, arrayformula(int(A2:A))}, "select max(Col1) where Col1 is not null group by Col2 label max(Col1) ''", 0)<>"", vlookup(query({A2:A, arrayformula(int(A2:A))}, "select max(Col1) where Col1 is not null group by Col2 label max(Col1) ''", 0), {A2:A,C2:C}, 2, false), "")))<>"", (arrayformula(if(query({A2:A, arrayformula(int(A2:A))}, "select max(Col1) where Col1 is not null group by Col2 label max(Col1) ''", 0)<>"", vlookup(query({A2:A, arrayformula(int(A2:A))}, "select max(Col1) where Col1 is not null group by Col2 label max(Col1) ''", 0), {A2:A,C2:C}, 2, false), "")))-QUERY((arrayformula(if(query({A2:A, arrayformula(int(A2:A))}, "select max(Col1) where Col1 is not null group by Col2 label max(Col1) ''", 0)<>"", vlookup(query({A2:A, arrayformula(int(A2:A))}, "select max(Col1) where Col1 is not null group by Col2 label max(Col1) ''", 0), {A2:A,C2:C}, 2, false), ""))), "SELECT * offset 1", 0), "")*-1)),">0")

Dummy file is here, formula is on D4 :虚拟文件在这里,公式在D4上:

https://docs.google.com/spreadsheets/d/1ExXtmQ8nyuV1o_UtabVJ-TifIbORItFMWjtN6ZlruWc/edit?usp=sharing https://docs.google.com/spreadsheets/d/1ExXtmQ8nyuV1o_UtabVJ-TifIbORItFMWjtN6ZlruWc/edit?usp=sharing

Any suggestions?有什么建议么?

try:尝试:

=INDEX(AVERAGE(QUERY(IFNA(QUERY(
 INDEX(SORTN(SORT({INT(A3:A), C3:C}, ROW(A3:A), ), 9^9, 2, 1, 1),,2),  "offset 1", )-
 INDEX(SORTN(SORT({INT(A3:A), C3:C}, ROW(A3:A), ), 9^9, 2, 1, 1),,2)), "offset 1", )))

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM