It:Le funzioni SOMMA.SE e MATR.SOMMA.PRODOTTO in Calc

From NeoWiki

Revision as of 22:50, 18 November 2007 by Valterb (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search
Questo articolo non è aggiornato, o ha bisogno di cambiamenti strutturali o stilistici per conformarsi al resto del wiki.

La funzione SOMMA.SE appartiene alla categoria delle funzioni matematiche mentre la funzione MATR.SOMMA.PRODOTTO appartiene alle funzioni matrice. Queste funzioni permettono di lavorare con intervalli di celle che soddisfano qualche criterio. Prima di descriverle è bene spiegare la differenza tra una funzione (o formula) ed una funzione di matrice (o formula di matrice).

Formule e Formule di matrice

Una formula di matrice (o funzione di matrice) ti permette di svolgere calcoli che coinvolgono valori presenti in una matrice, p.e. in un intervallo rettangolare formato da almeno due celle adiacenti. Questa formula può gestire diversi valori simultaneamente. Può dare come risultato diversi valori, in modo che tu non sia costretto a riempire le celle di un intervallo trascinando il puntatore che si trova nell'angolo in basso a destra di una cella. Il risultato di una formula di matrice è un'altra matrice. Per confermare i dati in una formula di matrice devi premere i tasti Command-Shift-Invio. La formula viene inserita tra virgolette, ma non è possibile creare una fomula di matrice digitando manualmente le virgolette nella barra della formula.

Esempioe

Supponiamo che l'intervallo di celle A1:A20 contenga dei valori numerici. Per mostrare il risultato del prodotto tra i numeri contenuti in ognuna delle celle per 5 nell'intervallo di celle B1:B20 abbiamo due possibilità:
1) Clicca nella cella B1, digita la formula formula:

=A1*5

poi premi il tasto Invio. Adesso riempi l'intervallo di celle B1:B20 trascinando il puntatore. Vedi l'articolo Selecting and Filling a Cell Range (en) in questo stesso wiki.

2) Clicca nella cella B1, digita la formula:

=A1:A20*5

poi premi Command-Shift-Invio.
L'intervallo B1:B20 viene automaticamente riempito.

Funzione SOMMA.SE

Questa è una funzione matematica e non una funzione di matrice. Permette di sommare un intervallo di celle che costituiscono una matrice e soddisfano un certo criterio. Questi critri devono essere un numero o una stringa. La sintassi è:

=SOMMA.SE(intervallo_da_controllare;criterio;intervallo_somma)

Supponiamo che l'intervallo A1:A20 contenga determinati valori numerici interi.

  • Per sommare i numeri dispari di questo intervallo devi usare una colonna ausiliaria, per esempio la colonna B, che mostri la parità delle celle presenti nell'intervallo A1:A10.
  • Nella cella B1, scrivi la formula :
=VAL.DISPARI(A1:A20)
e premi i tasti Command-Shift-Invio.
  • In una cella vuota, scrivi la formula:
=SOMMA.SE(B1:B20;1;A1:A20)

o

=SOMMA.SE(B1:B20;"VERO";A1:A20)
e premi il tasto Invio.
  • Per la somma dei numeri nell'intervallo A1:A20 che è maggiore della media di questo intervallo, non c'è bidogno di una colonna ausiliaria, puoi scrivere la formula seguente in una cella vuota:
=SOMMA.SE(A1:A20;">"&MEDIA(A1:A20);A1:A20)


NotA – PUOI SOSTITUIRE LA FUNZIONE Somma.se con la formula di matrice SOMMA. La sintasi di questa funzione è:

=SOMMA((intervallo=criterio)*(somma_intervallo))

Per esempio, nei casi sopra esposti, puoi digitare:

=SOMMA((B1:B20=1)*(A1:A20))

or

=SOMMA((A1:A20>MEDIA(A1:A20))*(A1:A20))

in una cella vuota, e premere Command-Shift-Invio.

SUMPRODUCT Function

We suppose again that the range A1:A20 contains numeric values.

The SUMPRODUCT function is an array function As it returns a single number, it can be entered by pressing only the Return key. It can be used:
1) To calculate the scalar product of two vectors.

2) To get the number of cells in a range which meet some criteria. The syntax is:

=SUMPRODUCT(range=criteria)
  • Let us count the number of cells which contain odd numbers:
In an empty cell, enter the formula:
=SUMPRODUCT(ISODD(A1:A20))

and press Return.

  • Let us count the number of cells which contain numbers greater than the range average:
In an empty cell, enter the formula:
=SUMPRODUCT(A1:A20>AVERAGE(A1:A20))

and press Return.

  • Let us count the number of cells which contain numbers which are odd and greater than the range average:
In an empty cell, enter the formula:
=SUMPRODUCT((A1:A20>AVERAGE(A1:A20))*(ISODD(A1:A20)))

and press Return.

3) To add the numbers in a range which meet some criteria. The syntax is:

=SUMPRODUCT(sum_range;criteria)

or

=SUMPRODUCT((sum_range)*(criteria))

In each case, you can change the order of the factors.

  • Adding the odd numbers of a range:
    In an empty cell, enter one of the following formulas:
=SUMPRODUCT(A1:A20;ISODD(A1:A20))

or

=SUMPRODUCT((A1:A20)*(ISODD(A1:A20)))

and press Return.

  • Adding the numbers greater than the range average:
    In an empty cell, enter the formula:
=SUMPRODUCT(A1:A20;A1:A20>AVERAGE(A1:A20))

and press Return.

  • Adding the numbers odd and greater than the range average:
    In an empty cell, enter the formula:
=SUMPRODUCT((A1:A20>AVERAGE(A1:A20))*(ISODD(A1:A20))*(A1:A20))

and press Return.

Note Defining cell ranges can be helpful.
Let us suppose that the cells of the range A1:A10 contain the value "red" or the value "green", and that the cells of the range B1:B10 contain the value "big" or the value "small". To count the number of simultaneous occurrences of the values "red" and "small", we can enter the formula:

=SUMPRODUCT(A1:A10="red";B1:B10="small")

or

=SUMPRODUCT((A1:A10="red")*(B1:B10="small"))

in C1.
But we can also define the ranges A1:A10 and B1:B10. To do that:

  • Select the range A1:A10.
  • Go to the Data menu and choose Define Range….
  • In the Define Range Database window which appears, enter a Name, for example "color" (without quotes).
  • Clck on Add then on OK.
  • Do the same with the range B1:B10 which you can call "size"
  • You can now use the formula:
=SUMPRODUCT(color="red";size="small")

or

=SUMPRODUCT((color="red")*(size="small")).

Personal tools