SUMIF

Determines which values in a range of cells meet a specified criterion, then returns the sum of the matching values. Alternatively the function can determine which values in one range of cells meet a criterion, then return the sum of values in the corresponding cells in a second range of cells.

note

SUMIF can only apply a single criterion to a range. Use SUMIFS if you need to apply multiple criteria.


Σύνταξη

SUMIF(Range; Criterion [;SumRange])

Range: The range of cells to which the criterion is applied.

SUMIF supports the reference concatenation operator (~) only in the Range parameter, and only if the optional SumRange parameter is not given.

Κριτήριο: Κριτήριο είναι μια μοναδική αναφορά κελιού, αριθμού, ή κειμένου. Χρησιμοποιείται σε συγκρίσεις με περιεχόμενα κελιού.

Μια αναφορά σε κενό κελί ερμηνεύεται ως η αριθμητική τιμή 0.

Μια σύμφωνη έκφραση μπορεί να είναι:

Η αναζήτηση υποστηρίζει χαρακτήρες Υποκατάστασης (μπαλαντέρ) ή κανονικές εκφράσεις. Με ενεργοποιημένες τις κανονικές εκφράσεις, μπορείτε να εισαγάγετε "all.*", για παράδειγμα, για να βρείτε την πρώτη θέση του "all" ακολουθούμενη από οποιουσδήποτε χαρακτήρες. Εάν θέλετε να αναζητήσετε ένα κείμενο που είναι επίσης κανονική έκφραση, πρέπει είτε να προηγηθεί κάθε μεταχαρακτήρα ή τελεστή κανονικής έκφρασης με έναν χαρακτήρα "\" ή να περικλείσετε το κείμενο στο \Q...\E. Μπορείτε να ενεργοποιήσετε και να απενεργοποιήσετε την αυτόματη αξιολόγηση χαρακτήρων υποκατάστασης ή κανονικής έκφρασης στο - LibreOfficeDev Υπολογισμός - Υπολογισμός .

warning

Όταν χρησιμοποιείτε συναρτήσεις όπου ένα ή περισσότερα ορίσματα είναι συμβολοσειρές κριτηρίων αναζήτησης που αντιπροσωπεύουν κανονική έκφραση, η πρώτη προσπάθεια είναι η μετατροπή των κριτηρίων συμβολοσειρών σε αριθμούς. Παραδείγματος χάρη, το ".0" θα μετατραπεί σε 0.0 κ.ο.κ. Εάν είναι πετυχημένο, η συμφωνία δεν θα είναι συμφωνία κανονικής έκφρασης, αλλά αριθμητική συμφωνία. Όμως, όταν αλλάζετε στις τοπικές ρυθμίσεις όπου ο δεκαδικός διαχωριστής δεν είναι η τελεία, η μετατροπή της κανονικής έκφρασης λειτουργεί. Για να εξαναγκάσετε την αξιολόγηση της κανονικής έκφρασης αντί για την αριθμητική έκφραση, χρησιμοποιήστε κάποια έκφραση που δεν μπορεί να παρανοηθεί ως αριθμητική, όπως ".[0]", ή ".\0", ή "(?i).0".


SumRange: Optional. The range of cells from which values are summed. If no SumRange is given, the values in the Range are summed.

note

Αυτή η συνάρτηση είναι τμήμα του προτύπου της μορφής Open Document για εφαρμογές γραφείου (OpenDocument) έκδοσης 1.2. (ISO/IEC 26300:2-2015)


Παραδείγματα

Θεωρήστε τον ακόλουθο πίνακα

A

B

C

1

Όνομα προϊόντος

Sales

Revenue

2

μολύβι

20

65

3

στυλό

35

85

4

σημειωματάριο

20

190

5

βιβλίο

17

180

6

pencil-case

not

not


warning

Σε όλα τα παρακάτω παραδείγματα, οι περιοχές για τον υπολογισμό περιέχουν τη γραμμή #6 που αγνοείται, επειδή περιέχει κείμενο.


Simple usage

=SUMIF(C2:C6,">=100")

Sums only the values from range C2:C6 that are >=100. Returns 370 because cells C2:C3 do not meet the criterion. The values from Range are summed because no SumRange is given.

=SUMIF(B2:B5,">=20",C2:C6)

Sums values from the range B2:B6 only if the corresponding values in the range A1:A5 are >=20. Returns 340 because the fifth and sixth rows do not meet the criterion.

Using regular expressions

=SUMIF(A2:A6,"pen",C2:C5)

Sums values from the range C2:C6 only if the corresponding range in A2:A6 exactly match the letters "pen". Returns 85 because rows A2 and A4:A6 do not meet the criterion.

=SUMIF(A2:A6,"pen*",C2:C6)

Sums the values from the range C2:C6 only if the corresponding cell in range A2:A6 contains the letters "pen". Returns the value 150 because rows A4:A5 do not meet the criterion.

=SUMIF(ProductName,"pen*",Revenue)

A named range can be given as the Range or SumRange parameter. For example, if the columns in the above table are respectively named "ProductName", "Sales", and "Revenue", the function returns 150. This function will only work as described if you have defined the names of the columns using the Define Names dialog.

Reference to a cell as a criterion

If you need to change a criterion easily, you may specify it in a separate cell and use a reference to this cell in the condition of the SUMIF function. For example:

=SUMIF(A2:A6,E2,C2:C6)

If E2 = pen, the function returns 85 because the link to the cell is substituted with its contents.