Products

COMBIN function

PRO BASIC

The COMBIN function in Jspreadsheet Formulas Pro is a powerful tool that calculates the total number of possible combinations for a specified number of items. For example, if you have 5 different books and want to know how many ways you can choose 3 out of 5, the COMBIN function would give you the answer. You simply input the total number of items, and the number of items you want to combine, and the function does the rest. It's an easy and efficient way to solve combination problems.

Documentation

Returns the number of combinations for a given number of items.

Category

Math and trigonometry

Syntax

COMBIN(number, number_chosen)

Parameter Description
number The total number of items you have to choose from.
number_chosen The number of items you want to choose.

Behavior

The COMBIN function is used to calculate the number of combinations for a given number of items. It takes two arguments: the total number of items and the number of items in each combination. Here's how it handles different inputs:

  • Empty cells: If either argument is an empty cell, COMBIN will return a #NUM! error, unless handled by a wrapper function like IFERROR.
  • Text: If either of the arguments is text, the COMBIN function will return a #VALUE! error.
  • Booleans: If either of the arguments is a boolean value (TRUE or FALSE), the COMBIN function will coerce the boolean into an integer (TRUE to 1, FALSE to 0) before executing.
  • Errors: If either of the arguments contains an error, the COMBIN function will return that error.
  • Non-integers: If non-integer values are used, they will be floored (i.e., truncated toward zero) before calculation.
  • Negative numbers: If either of the arguments is negative, the COMBIN function will return a #NUM! error.

Common Errors

Error Description
#VALUE! This error is returned when one or both of the arguments are non-numeric, or if the cells are empty.
#NUM! Returned when arguments are negative, or if number_chosen is greater than number.

Best practices

  1. Ensure both the total number of items and the number of items in each combination are positive integers.
  2. Be aware that if the number of combinations is larger than the total number of items, the COMBIN function will return a #NUM! error.
  3. Keep in mind that if non-integer values are used, they will be truncated to integers.
  4. Utilize error handling functions like IFERROR to manage potential errors in your COMBIN formula.

Usage

A few examples using the COMBIN function.

COMBIN(5, 3) returns 10  
COMBIN(8, 2) returns 28  
COMBIN(10, 1) returns 10  

Interactive Spreadsheet Demo

<html>
<script src="https://jspreadsheet.com/v11/jspreadsheet.js"></script>
<script src="https://jsuites.net/v5/jsuites.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v5/jsuites.css" type="text/css" />
<link rel="stylesheet" href="https://jspreadsheet.com/v11/jspreadsheet.css" type="text/css" />

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons" />
<script src="https://cdn.jsdelivr.net/npm/@jspreadsheet/formula-pro/dist/index.min.js"></script>

<div id="spreadsheet"></div>

<script>
// Set your JSS license key (The following key only works for one day)
jspreadsheet.setLicense('M2E5NWJiNjc3OGRkNmNmMmI5YjJiODI1ZWU1ZjYzZGQ1NDhiOGQ3ZGFlYjQxZGVhNTZlZDZmMDQ3MTZiMWY0ZWQzMGQ1YjRlYTBmMjljNmRmYjZlNGJlMzIyY2YyYzllOTM3MWU4ZjgyMmY1N2NlNTE4MjQ4MzYwYWRhNDMxZWIsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpVM01EY3pNekV3TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2lkMlZpSWl3aWJHOWpZV3hvYjNOMElsMHNJbkJzWVc0aU9pSXpOQ0lzSW5OamIzQmxJanBiSW5ZM0lpd2lkamdpTENKMk9TSXNJbll4TUNJc0luWXhNU0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklpd2lZMnhwWlc1MElpd2ljMlZ5ZG1WeUlpd2ljMmhoY0dWeklpd2labTl5YldGMElsMHNJbVJsYlc4aU9uUnlkV1Y5');

// Set the extensions
jspreadsheet.setExtensions({ formula });

// Create a new spreadsheet
jspreadsheet(document.getElementById('spreadsheet'), {
  worksheets: [{
    data: [
    [
        "Total Items",
        "Items Chosen",
        "Combinations"
    ],
    [
        8,
        3,
        "=COMBIN(A2,B2)"
    ],
    [
        10,
        4,
        "=COMBIN(A3,B3)"
    ],
    [
        12,
        2,
        "=COMBIN(A4,B4)"
    ],
    [
        6,
        5,
        "=COMBIN(A5,B5)"
    ]
]
  }]
});
</script>
</html>
import React, { useRef } from "react";
import { Spreadsheet, Worksheet, jspreadsheet } from "@jspreadsheet/react";
import formula from "@jspreadsheet/formula-pro";
import "jsuites/dist/jsuites.css";
import "jspreadsheet/dist/jspreadsheet.css";

// Set license
jspreadsheet.setLicense('M2E5NWJiNjc3OGRkNmNmMmI5YjJiODI1ZWU1ZjYzZGQ1NDhiOGQ3ZGFlYjQxZGVhNTZlZDZmMDQ3MTZiMWY0ZWQzMGQ1YjRlYTBmMjljNmRmYjZlNGJlMzIyY2YyYzllOTM3MWU4ZjgyMmY1N2NlNTE4MjQ4MzYwYWRhNDMxZWIsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpVM01EY3pNekV3TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2lkMlZpSWl3aWJHOWpZV3hvYjNOMElsMHNJbkJzWVc0aU9pSXpOQ0lzSW5OamIzQmxJanBiSW5ZM0lpd2lkamdpTENKMk9TSXNJbll4TUNJc0luWXhNU0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklpd2lZMnhwWlc1MElpd2ljMlZ5ZG1WeUlpd2ljMmhoY0dWeklpd2labTl5YldGMElsMHNJbVJsYlc4aU9uUnlkV1Y5');

// Set the extensions
jspreadsheet.setExtensions({ formula });

export default function App() {
    // Spreadsheet array of worksheets
    const spreadsheet = useRef();

    // Worksheet data
    const data = [
    [
        "Total Items",
        "Items Chosen",
        "Combinations"
    ],
    [
        8,
        3,
        "=COMBIN(A2,B2)"
    ],
    [
        10,
        4,
        "=COMBIN(A3,B3)"
    ],
    [
        12,
        2,
        "=COMBIN(A4,B4)"
    ],
    [
        6,
        5,
        "=COMBIN(A5,B5)"
    ]
];

    // Render component
    return (
        <Spreadsheet ref={spreadsheet}>
            <Worksheet data={data} />
        </Spreadsheet>
    );
}
<template>
    <Spreadsheet ref="spreadsheet">
        <Worksheet :data="data" />
    </Spreadsheet>
</template>

<script>
import { Spreadsheet, Worksheet, jspreadsheet } from "@jspreadsheet/vue";
import "jsuites/dist/jsuites.css";
import "jspreadsheet/dist/jspreadsheet.css";
import formula from "@jspreadsheet/formula-pro";

// Set license
jspreadsheet.setLicense('M2E5NWJiNjc3OGRkNmNmMmI5YjJiODI1ZWU1ZjYzZGQ1NDhiOGQ3ZGFlYjQxZGVhNTZlZDZmMDQ3MTZiMWY0ZWQzMGQ1YjRlYTBmMjljNmRmYjZlNGJlMzIyY2YyYzllOTM3MWU4ZjgyMmY1N2NlNTE4MjQ4MzYwYWRhNDMxZWIsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpVM01EY3pNekV3TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2lkMlZpSWl3aWJHOWpZV3hvYjNOMElsMHNJbkJzWVc0aU9pSXpOQ0lzSW5OamIzQmxJanBiSW5ZM0lpd2lkamdpTENKMk9TSXNJbll4TUNJc0luWXhNU0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklpd2lZMnhwWlc1MElpd2ljMlZ5ZG1WeUlpd2ljMmhoY0dWeklpd2labTl5YldGMElsMHNJbVJsYlc4aU9uUnlkV1Y5');

// Set the extensions
jspreadsheet.setExtensions({ formula });

export default {
    components: {
        Spreadsheet,
        Worksheet,
    },
    data() {
        // Worksheet data
        const data = [
    [
        "Total Items",
        "Items Chosen",
        "Combinations"
    ],
    [
        8,
        3,
        "=COMBIN(A2,B2)"
    ],
    [
        10,
        4,
        "=COMBIN(A3,B3)"
    ],
    [
        12,
        2,
        "=COMBIN(A4,B4)"
    ],
    [
        6,
        5,
        "=COMBIN(A5,B5)"
    ]
]

        return {
            data
        };
    }
}
</script>
import { Component, ViewChild, ElementRef } from "@angular/core";
import jspreadsheet from "jspreadsheet";
import * as formula from "@jspreadsheet/formula-pro";

// Set your JSS license key (The following key only works for one day)
jspreadsheet.setLicense('M2E5NWJiNjc3OGRkNmNmMmI5YjJiODI1ZWU1ZjYzZGQ1NDhiOGQ3ZGFlYjQxZGVhNTZlZDZmMDQ3MTZiMWY0ZWQzMGQ1YjRlYTBmMjljNmRmYjZlNGJlMzIyY2YyYzllOTM3MWU4ZjgyMmY1N2NlNTE4MjQ4MzYwYWRhNDMxZWIsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpVM01EY3pNekV3TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2lkMlZpSWl3aWJHOWpZV3hvYjNOMElsMHNJbkJzWVc0aU9pSXpOQ0lzSW5OamIzQmxJanBiSW5ZM0lpd2lkamdpTENKMk9TSXNJbll4TUNJc0luWXhNU0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklpd2lZMnhwWlc1MElpd2ljMlZ5ZG1WeUlpd2ljMmhoY0dWeklpd2labTl5YldGMElsMHNJbVJsYlc4aU9uUnlkV1Y5');

// Set the extensions
jspreadsheet.setExtensions({ formula });

@Component({
    standalone: true,
    selector: "app-root",
    template: `<div #spreadsheet></div>`
})
export class AppComponent {
    @ViewChild("spreadsheet") spreadsheet: ElementRef;
    // Worksheets
    worksheets: jspreadsheet.worksheetInstance[];

    // Create a new data grid
    ngAfterViewInit() {
        // Create spreadsheet
        this.worksheets = jspreadsheet(this.spreadsheet.nativeElement, {
            worksheets: [{
                data: [
    [
        "Total Items",
        "Items Chosen",
        "Combinations"
    ],
    [
        8,
        3,
        "=COMBIN(A2,B2)"
    ],
    [
        10,
        4,
        "=COMBIN(A3,B3)"
    ],
    [
        12,
        2,
        "=COMBIN(A4,B4)"
    ],
    [
        6,
        5,
        "=COMBIN(A5,B5)"
    ]
]
            }]
        });
    }
}