質問

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 で次の関数を使用していて、それを MS SQL に解釈する必要があります。SQLには詳しいのですが、Excelにはあまり詳しくありません。私が理解しているところによると、エラーの場合、関数は「」を返しています。それ以外の場合は、最も内側の括弧で SUMIF を呼び出しています。Excel で !、:、$ が何をするのか調べても、その中で何が起こっているのかわかりません。

役に立ちましたか?

解決

SUMIFS() セル範囲に適用される 1 つ以上の基準に基づいてセル範囲を追加します。

最初は合計する値の範囲で、その後に基準のペアが続きます。最初に基準の範囲、次に基準が続きます。最初のものは次のように分解されます。

    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

これは数式の分子であり、2 番目の 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