IFERROR((SUMIFS('Sheet 1'!$K:$K,'Sheet 1'!$A:$A,'Sheet 2'!I$5,'Sheet 1'!$C:$C,'Sheet 2'!$B15,'Sheet 1'!$K:$K,"<>0"))/(SUMIFS('Sheet 1'!$J:$J,'Sheet 1'!$A:$A,'Sheet 2'!I$5,'Sheet 1'!$C:$C,'Sheet 2'!$B15,'Sheet 1'!$K:$K,"<>0")),"")
.

我在Excel中使用以下功能,需要将其解释为SQL MS。我熟悉SQL,但非常不熟悉Excel。从我理解的是,函数正在返回“”如果错误。否则,它在最内部括号中调用sumif - 其中我不确定发生了什么,即使在查找什么之后!,:和$ do在Excel

有帮助吗?

解决方案

SUMIFS()基于应用于一系列单元的一个或多个标准添加一系列单元格。

首先是要总结的值范围,然后在该标准对之后,首先是标准范围,然后是标准。第一个分手这样的东西:

    SUMIFS('Sheet 1'!$K:$K   -- Sum this field
            ,'Sheet 1'!$A:$A,'Sheet 2'!I$5  --When same row in A matches Sheet 2 I5
            ,'Sheet 1'!$C:$C,'Sheet 2'!$B15 --When same row in C matches Sheet 2 B, but 15 rows down.
            ,'Sheet 1'!$K:$K,"<>0")  --When the values aren't 0
.

这是公式中的分子,您可以类似地分解2nd sumif()。

其他提示

好的,因为我不知道你的工作表是什么,我无法帮助你的SQL,但我会尝试和打破你的函数

#this part is for if the enclosed returns an error like #VALUE
#you can think of this as a try rescue block of sorts
#so if there is an Error then Return ""
IFERROR(
  (
   #This part is Summing All the values in Column K for multiple criteria
   #Sum all the values in Column K ref ['Sheet 1'!$K:$K]
   #Where all the values in Column A  = Value in Cell I5 ref['Sheet 1'!$A:$A,'Sheet 2'!I$5]
   #And Values in Column C = Value in Cell B15 ref [ 'Sheet 1'!$C:$C,'Sheet 2'!$B15]
   #And the Values in Column K Do not = 0 ref ['Sheet 1'!$K:$K,"<>0"]
   SUMIFS('Sheet 1'!$K:$K,'Sheet 1'!$A:$A,'Sheet 2'!I$5,'Sheet 1'!$C:$C,'Sheet 2'!$B15,'Sheet 1'!$K:$K,"<>0")
  #Above Number Divided By 
  )/(
   #This part is Summing All the values in Column J for multiple criteria
   #Sum all the values in Column J ref ['Sheet 1'!$J:$J]
   #Where all the values in Column A  = Value in Cell I5 ref['Sheet 1'!$A:$A,'Sheet 2'!I$5]
   #And Values in Column C = Value in Cell B15 ref [ 'Sheet 1'!$C:$C,'Sheet 2'!$B15]
   #And the Values in Column K Do not = 0 ref ['Sheet 1'!$K:$K,"<>0"]
  SUMIFS('Sheet 1'!$J:$J,'Sheet 1'!$A:$A,'Sheet 2'!I$5,'Sheet 1'!$C:$C,'Sheet 2'!$B15,'Sheet 1'!$K:$K,"<>0")
  )
,"")
.

这是 sumifs 。快速概要:

*First Argument is the Rows being Summed
*Second Argument is the Criteria Being Evaulated
*Third Argument is the Expression Being Evaluated Against
*Repeat Second and Third for all additional Criterium
.

黑色sql

SELECT Sum(Sheet1.ColumnK) / Sum(Sheet2.ColumnJ)
FROM Sheet1 JOIN Sheet2 
WHERE
Sheet1.ColumnA = 10 --I Used 10 in place of Sheet2.ColumnI Row5 as this does not translate directly in SQL
AND Sheet1.ColumnC = 20 -- Same As Above Substitution for Sheet2.ColumnB Row 15
AND Sheet1.ColumnK <> 0
.

希望这有助于

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top