Search code examples
libreoffice-calc

How to create an index using LibreOffice Calc (no macro)


I need to create a list of items in LibreOffice Calc, listing description and price; on another sheet I need to group specific items and make the line total.

My items list has the following IDs (1,2,4,8,...32,64,128,etc..) this way when I sum 2 or more items I obtain an unique ID, this ID so obtained describes of what elements it is composed in one line, so ID 7 is the sum of the first three.

I need to enter these ID in one sheet and lookup the total price on a near cell, let's make an example with numbers:

Sheet 1
 1 Price 10
 2 Price 35
 4 Price 80
 8 Price 16
16 Price  8
32 Price 29

Sheet 2
 7 Total Price 125
18 Total Price  43
35 Total Price  74

Solution

  • This is ugly, but might give you something to develop. First the list in Sheet1 needs to be in reverse order. I added 64 in A1 (0 in C1) then 32 in A2 etc.

    In Sheet2 (where 7 is in A2 etc) in D2 and copied down to suit:

    =BASE(A2,2,7)
    

    (You might need to increase the 7, depending upon how many Total Prices you have.)

    Then on ColumnD Text to Columns..., Fixed width and parsed (Standard) at every character position.

    Finally, in L2 and copied down to suit:

    =SUMPRODUCT(Sheet1.C$1:C$7,TRANSPOSE(D2:J2))