Domanda

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")),"")
.

Sto lavorando con la seguente funzione in Excel e ho bisogno di interpretarlo in MS SQL.Ho familiarità con SQL, ma estremamente sconosciuto con Excel.Da ciò che capisco che la funzione sta tornando "" se errore.Altrimenti sta chiamando Sumif sulle parentesi più interne - dentro di cui non sono sicuro di cosa sta succedendo, anche dopo aver cercato cosa!, :, e $ do in Excel

È stato utile?

Soluzione

SUMIFS() aggiunge una gamma di celle basate su uno o più criteri applicati a una gamma di celle.

Prima è la gamma di valori da riattivare, quindi dopo che arrivano coppie di criteri, prima è la gamma dei criteri, quindi i criteri.Il primo rompe qualcosa del genere:

    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
.

Questo è il numeratore nella tua formula, puoi abbattere il 2 ° Sumif () allo stesso modo.

Altri suggerimenti

Okay Dato che non ho idea di quello che hai foglio non posso aiutare con lo SQL ma proverò a rompere la funzione per te

#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")
  )
,"")
.

Ecco la definizione di Sumifs .Sinossi rapida:

*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
.

hacked 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
.

Spero che questo aiuti

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top