With the following formula you can accomplish that.
Formula
=QUERY(DATA!D2:F15, "SELECT D, SUM(F) GROUP BY D PIVOT E LABEL D 'Politicians'")
Explained
The QUERY
function will group the summation of the costs per politician and pivot the outcome per type.
Screenshot
Example
I've prepared an example for you: overview with query and pivot
I would suggest using dget
in the first sheet, if the number of users is defined, and doesn't grow automatically.
Assuming the second sheet is Sheet2, I would add 2 columns to the first sheet.
The first column would have cells with the formula (changing the cells accordingly, with copy and paste):
=dget(Sheet2!$A:$C,"PAID ACCOUNT",{"USER ID";$A2})
The second column would have cells with the formula (changing the cells accordingly, with copy and paste):
=dget(Sheet2!$A:$C,"ACCOUNT ID",{"USER ID";$A2})
You could also try a more direct approach, by using cell references in the "field" section, such as:
=dget(Sheet2!$A:$C,Sheet2!B$1,{"USER ID";$A2})
After this, you would only need to copy and paste the formula in all the cells that require importing.
If the list grows or is fed from a form, then this solution would not apply.
Best Answer
You can link two cells using a google script. You can use on Edit trigger of each sheet to poll for which cell is getting modified and modify the other one in the other sheet.
The below code will link cell A1 in "Sheet1" in of Spreadsheet with ID spd1ID to B1 in "Sheet1" in Spreadsheet with ID spd2ID
Where to paste this code? Open your spreadsheet Tools>Script Editor
What is spreadsheet ID? https://developers.google.com/sheets/api/guides/concepts#spreadsheet_id
After you paste the code and modify the ID, run myLinkCells() function using Run menu. That will link the cells.
Hope that helps!