0

In LibreOffice Calc I have created a die rolling sheet. In A6:B1005 I list the values in column A and number of die rolls with that value in column B. Example with a d10:

Die Value Number of rolls
1 7
2 10
3 8
4 8
5 15
6 16
7 7
8 9
9 13
10 7
11 0
12 0

Cell D3 has defined the number of sides of the die.

What I want to do, is get the minimum and maximum value from column B within the range of die sides accounted for. My current formula is {=MIN(IF(A6:A10005 >= D3; B6:B10005))}, but this returns 0. How can I change the formula to account for the value in D3? In other words, I want to return the minimum value in the range B6:B1005 exclusively including values where A6:A1005 >= D3.

1 Answer 1

0

I was able to figure it out last night, and here is how:

Images and formulas

Cell D2 and D3 define the number of dice and the number of sides for each die:
Number of dice and number of faces for each die
Count: 100d. Sides: d20

Cells A6:Bn list the result of the die and the number of results for each face:
List of die results
Die, value and count for each face of the die rolls.

In cells A3:B3 I list the low and high with count in parentheses:
Lowest and highest result with count in parentheses.
Low and high: 16(1)/6(11)

In order to write this function, I had to result in a quite horrible nested concatenate, but it got the job done:

=KJED.SAMAN(INDEKS(A6:A10005;
SAMANLIKNA(N.MINST(B6:B10005;
TEL.VISS(A6:A10005;">="&D3));B6:B10005;0));
"(";N.MINST(B6:B10005;
TEL.VISS(A6:A10005;">="&D3));")/";INDEKS(A6:A10005;
SAMANLIKNA(N.STØRST(B6:B10005;1);B6:B10005;0));
"(";MAKS(B6:B10005);")")

=CONCATENATE(INDEX(A6:A10005;
MATCH(SMALL(B6:B10005;
COUNT.IF(A6:10005;">="&D3));B6:B10005;0));
"(";SMALL(B6:B10005;
COUNT.IF(A6:A10005;">="&D3);")/";INDEX(A6:A10005;
SAMANLIKNA(LARGE(B6:B10005;1);B6:B10005;0));
"(";MAX(B6:B10005);")")

Explanation

What this does is in practice a left LOOKUP.

How MATCH works

`=MATCH(search criteria; search range; type[0,1])

By looking in a source cell, e.g. B1 containing the value 101, then looking in a data range, e.g. a list of products, the value returns which number in the list the data is found. Example:

  A                   B
1 Enter product type: 902
2
3 Jackets             900
4 Trousers            901
5 Shoes               902

For this example, MATCH would return the value 3 if looking in the area B3:B5, as ‘102’ is the third row matching the product number entered in B1.

Combining this with INDEX

By looking at a specified source, we can collect the relevant data. We have already collected the number 4. The structure is INDEX(reference;row;column;area). Let us improve on our data example:

A B C D E F
1 Product type: 902
2
3 Prod. no. Item Brand Item Prod. no.
4 900 Nykë Jackets 900
5 901 Leevys Trousers 901
6 902 Nykë Shoes 902
7 903 Benzin Hats 903
8 904 Leevys Scarfs 904
A B C D E F

In cell B4, we can enter the function =INDEX(E$4:E$8;MATCH(B4;F$4:F$8;0)), and then paste that down the range B4:B8. What this will do, is look in the range of items in the range E4:E8, it will then for its row go to the MATCH formula, in which we first get the data entered by the employee in B4 (item no. 902), then look in the range F4:F8 to find that number, and finally return this to the index, which lists the expected ‘Shoes’ in cell B4.

SMALL and LARGE

Finally, there was the issue of getting the correct small number. MIN didn’t work, as that included zeros. I needed the formula to look in the entire range, as the number of faces on the die could increase. (In Hackmaster, we even use a d10000 for critical hits.) Let us have a look at the formula again:

SMALL(B6:B10005;COUNT.IF(A6:10005;">="&D3))

What this does, is look in the range B6:B10005, which is where the number of hits for each result is listed, then use a COUNT.IF to find the number in the left column where the possible die faces are listed, and then finally collecting the maximum number from the cell (D3) where the number of die faces are stated. The reason the criterium is written the way it is (">="&D3), is that the criterium when not a number must be expressed within quotes. The expression is joined with the cell reference via the ampersand.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .