Pivot Tables are a very useful feature in Spreadsheets, they allow you to do things that might otherwise require code to iterate around on. My mental model of them is not great though I find there is a great deal of trial and error to get them working for me.
Anyway I recently had to calculate a weighted average and found this web page:
very useful. Essentially you need to add an extra column in your data with an intermediate step of weight*value that you can then sum in the pivot table.
Although the tutorial example there is done in Excel I actual used Libreoffice as despite the fact I now mainly fill out electronic paperwork I have clung onto my Linux box 🙂