Hello everyone,
for our childrens orgranisation we are doing some easy accounting reports. It is sufficient for our purpose, but I am stuck on one partial problem.
On first sheet are input data (financial diary) in 2NF format. So if one cost is "multi-sourced" it is mentioned on multiple lines with same redundant data except the source of financing. This method of entry is satisfactory because of its ease of legibility and comprehensibility:
On the second sheet is the desired overview of actions and its costs by sources:
I cannot figure out, how to filter costs by its source, more precisely how to display its value in a proper position when split by source.
I have tried to implement these rules in FILTER function:
A) Is it a "single source" cost AND is in current column/source? → put one row and whole cost
B) Is it a "single source" cost AND is in different column/source? → put one row and whole cost
C) Is it a "multi-source" cost AND in current column/source? → skip other rows and put its partial cost
D) Is it a "multi-source" cost AND in different column/source? → skip other rows and put its partial cost
Those two last rules are not working well. Problem is I would need to "pre-filter" the data, that comes to FILTER function, so the output would skip the empty lines correctly. Like add a rule something like "IF it is a multi-sourced cost AND it is in a current column/source AND has not been mentioned yet"...:
For a better view of the data you can download the whole table here:
Notes:
Thank you for your ideas.
for our childrens orgranisation we are doing some easy accounting reports. It is sufficient for our purpose, but I am stuck on one partial problem.
On first sheet are input data (financial diary) in 2NF format. So if one cost is "multi-sourced" it is mentioned on multiple lines with same redundant data except the source of financing. This method of entry is satisfactory because of its ease of legibility and comprehensibility:
filter_costs_source_small.xlsx | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
B | C | D | E | F | G | H | I | J | K | L | M | |||
1 | formula based values | |||||||||||||
2 | Financial diary | |||||||||||||
3 | ↓ count of sources of all costs | ↓ order in case of multi-sourced costs | ↓ Is it a multi-sourced cost? | ↓ for conditional visual separator (line) of multi-sourced costs | ||||||||||
4 | ||||||||||||||
5 | Operation ID | Date | Item | Cost | Total cost | Action | Source | Helper 0 (cost) | Helper 1 | Helper 2 | Helper 3 | Helper 4 | ||
6 | 180 | 10.06.2022 | Material (gas) | -278,00 | Action 1 | Source C | 278,00 | 1 | 0 | YES | ||||
7 | 181 | 11.06.2022 | Material (building) | -1 900,00 | Action 1 | Source B | 5 083,00 | 3 | 1 | YES | ||||
8 | 181 | 11.06.2022 | Material (building) | -2 100,00 | Action 1 | Source C | 5 083,00 | 3 | 2 | YES | ||||
9 | 181 | 11.06.2022 | Material (building) | -1 083,00 | -5 083,00 | Action 1 | Source D | 5 083,00 | 3 | 3 | YES | YES | ||
10 | 184 | 16.06.2022 | Material (saw blade) | -828,00 | Action 1 | Source B | 828,00 | 1 | 0 | |||||
11 | 200 | 29.06.2022 | Material (screws) | -162,00 | Action 1 | Source C | 162,00 | 1 | 0 | YES | ||||
12 | 212 | 30.06.2022 | Material (steel pot) | -2 258,00 | Action 1 | Source C | 4 258,00 | 2 | 1 | YES | ||||
13 | 212 | 30.06.2022 | Material (steel pot) | -2 000,00 | -4 258,00 | Action 1 | Source D | 4 258,00 | 2 | 2 | YES | YES | ||
14 | 214 | 11.07.2022 | Food | -952,00 | Action 1 | Source B | 952,00 | 1 | 0 | YES | ||||
15 | 215 | 11.07.2022 | Material (building) | -1 100,00 | Action 1 | Source B | 2 674,00 | 2 | 1 | YES | ||||
16 | 215 | 11.07.2022 | Material (building) | -1 574,00 | -2 674,00 | Action 1 | Source C | 2 674,00 | 2 | 2 | YES | YES | ||
17 | 216 | 11.07.2022 | Material (fabrics) | -755,00 | Action 1 | Source C | 755,00 | 1 | 0 | YES | ||||
18 | 218 | 14.07.2022 | Material (plasters) | -580,00 | Action 1 | Source B | 1 080,00 | 2 | 1 | YES | ||||
19 | 218 | 14.07.2022 | Material (plasters) | -500,00 | -1 080,00 | Action 1 | Source D | 1 080,00 | 2 | 2 | YES | YES | ||
20 | 220 | 15.07.2022 | Services (health) | -250,00 | Action 1 | Source B | 250,00 | 1 | 0 | |||||
21 | 227 | 18.07.2022 | Material (pharmacy) | -198,00 | Action 1 | Source C | 198,00 | 1 | 0 | YES | ||||
22 | 228 | 18.07.2022 | Food | -909,00 | Action 1 | Source B | 1 109,00 | 2 | 1 | YES | ||||
23 | 228 | 18.07.2022 | Food | -200,00 | -1 109,00 | Action 1 | Source C | 1 109,00 | 2 | 2 | YES | YES | ||
24 | 230 | 20.07.2022 | Services (waste fee) | -300,00 | Action 1 | Source B | 300,00 | 1 | 0 | |||||
25 | 238 | 24.07.2022 | Material (organizer, rail) | -957,00 | Action 1 | Source C | 957,00 | 1 | 0 | YES | ||||
26 | 239 | 25.07.2022 | Transportation (cars) | -1 100,00 | Action 1 | Source B | 3 542,00 | 3 | 1 | YES | ||||
27 | 239 | 25.07.2022 | Transportation (cars) | -900,00 | Action 1 | Source C | 3 542,00 | 3 | 2 | YES | ||||
28 | 239 | 25.07.2022 | Transportation (cars) | -1 542,00 | -3 542,00 | Action 1 | Source D | 3 542,00 | 3 | 3 | YES | YES | ||
29 | 240 | 25.07.2022 | Admission (swimming pool) | -886,00 | Action 1 | Source B | 886,00 | 1 | 0 | |||||
30 | 241 | 27.07.2022 | Material (markers) | -33,00 | Action 1 | Source D | 33,00 | 1 | 0 | |||||
31 | 249 | 30.07.2022 | Services (water supply) | -160,00 | Action 1 | Source B | 160,00 | 1 | 0 | YES | ||||
32 | 339 | 31.08.2022 | Postal service | -433,00 | Action 2 | Source A | 437,00 | 2 | 1 | YES | ||||
33 | 339 | 31.08.2022 | Postal service | -4,00 | -437,00 | Action 2 | Source B | 437,00 | 2 | 2 | YES | YES | ||
34 | 343 | 04.09.2022 | Material (creative) | -160,00 | Action 2 | Source A | 160,00 | 1 | 0 | |||||
35 | 420 | 27.10.2022 | Entrance fee (exhibition) | -1 140,00 | Action 2 | Source C | 1 140,00 | 1 | 0 | YES | ||||
36 | 422 | 28.10.2022 | Transport (bus) | -200,00 | Action 2 | Source A | 890,00 | 3 | 1 | YES | ||||
37 | 422 | 28.10.2022 | Transport (bus) | -500,00 | Action 2 | Source B | 890,00 | 3 | 2 | YES | ||||
38 | 422 | 28.10.2022 | Transport (bus) | -190,00 | -890,00 | Action 2 | Source C | 890,00 | 3 | 3 | YES | YES | ||
39 | 423 | 28.10.2022 | Services (hospital) | -80,00 | Action 2 | Source A | 80,00 | 1 | 0 | |||||
40 | 426 | 28.10.2022 | Entrance fee (swimming pool) | -1 670,00 | Action 2 | Source C | 1 670,00 | 1 | 0 | YES | ||||
41 | 428 | 29.10.2022 | Food | -1 775,00 | Action 2 | Source A | 2 775,00 | 2 | 1 | YES | ||||
42 | 428 | 29.10.2022 | Food | -1 000,00 | -2 775,00 | Action 2 | Source B | 2 775,00 | 2 | 2 | YES | YES | ||
43 | 429 | 30.10.2022 | Food | -460,00 | Action 2 | Source A | 460,00 | 1 | 0 | |||||
44 | 433 | 01.11.2022 | Transport (train) | -274,00 | Action 2 | Source A | 274,00 | 1 | 0 | YES | ||||
45 | 540 | 08.12.2022 | Accommodation | -2 000,00 | Action 2 | Source B | 6 600,00 | 2 | 1 | YES | ||||
46 | 540 | 08.12.2022 | Accommodation | -4 600,00 | -6 600,00 | Action 2 | Source C | 6 600,00 | 2 | 2 | YES | YES | ||
47 | 544 | 09.12.2022 | Administrative fee | -300,00 | Action 2 | Source B | 300,00 | 1 | 0 | |||||
Data (input) |
Cell Formulas | ||
---|---|---|
Range | Formula | |
I6:I47 | I6 | =SUMIF([Operation ID], [@[Operation ID]], [Cost]) * -1 |
J6:J47 | J6 | =COUNTIFS([Operation ID], [@[Operation ID]]) |
K6:K47 | K6 | =IF([@[Helper 1]] > 1, COUNTIF(data[[#Headers],[Operation ID]]:[@[Operation ID]], [@[Operation ID]]), 0) |
L6:L47 | L6 | =IF([@[Helper 2]] > 0, "YES", "") |
M6:M47 | M6 | =IF(OR([@[Helper 3]] <> OFFSET([@[Helper 3]], 1, 0), AND([@[Helper 2]] > OFFSET([@[Helper 2]], -1, 0), OFFSET([@[Helper 2]], -1, 1) <> 0, [@[Helper 2]] > OFFSET([@[Helper 2]], 1, 0))), "YES", "") |
F6:F47 | F6 | =IF(AND([@[Helper 4]] = "YES", [@[Helper 3]] = "YES"), SUMIF([Operation ID], [@[Operation ID]], [Cost]), "") |
Cells with Conditional Formatting | ||||
---|---|---|---|---|
Cell | Condition | Cell Format | Stop If True | |
E6:E47 | Expression | =$L6 = "" | text | NO |
B6:M47 | Expression | =$M6 <> "" | text | NO |
On the second sheet is the desired overview of actions and its costs by sources:
filter_costs_source_small.xlsx | ||||||||
---|---|---|---|---|---|---|---|---|
J | K | L | M | N | O | |||
3 | Overview of costs by source (desired form of output) | |||||||
4 | Action 1 (sample proper solution) | |||||||
5 | ...of which covered by | |||||||
6 | Date | Item | Total cost… | Source B | Source C | Source D | ||
7 | 10.06.2022 | Material (gas) | 278,00 | 278,00 | ||||
8 | 11.06.2022 | Material (building) | 5 083,00 | 1 900,00 | 2 100,00 | 1 083,00 | ||
9 | 16.06.2022 | Material (saw blade) | 828,00 | 828,00 | ||||
10 | 29.06.2022 | Material (screws) | 162,00 | 162,00 | ||||
11 | 30.06.2022 | Material (steel pot) | 4 258,00 | 2 258,00 | 2 000,00 | |||
12 | 11.07.2022 | Food | 952,00 | 952,00 | ||||
13 | 11.07.2022 | Material (building) | 2 674,00 | 1 100,00 | 1 574,00 | |||
14 | 11.07.2022 | Material (fabrics) | 755,00 | 755,00 | ||||
15 | 14.07.2022 | Material (plasters) | 1 080,00 | 580,00 | 500,00 | |||
16 | 15.07.2022 | Services (health) | 250,00 | 250,00 | ||||
17 | 18.07.2022 | Material (pharmacy) | 198,00 | 198,00 | ||||
18 | 18.07.2022 | Food | 1 109,00 | 909,00 | 200,00 | |||
19 | 20.07.2022 | Services (waste fee) | 300,00 | 300,00 | ||||
20 | 24.07.2022 | Material (organizer, rail) | 957,00 | 957,00 | ||||
21 | 25.07.2022 | Transportation (cars) | 3 542,00 | 1 100,00 | 900,00 | 1 542,00 | ||
22 | 25.07.2022 | Admission (swimming pool) | 886,00 | 886,00 | ||||
23 | 27.07.2022 | Material (markers) | 33,00 | 33,00 | ||||
24 | 30.07.2022 | Services (water supply) | 160,00 | 160,00 | ||||
25 | ||||||||
26 | Action 2 (sample proper solution) | |||||||
27 | ...of which covered by | |||||||
28 | Date | Item | Total cost… | Source A | Source B | Source C | ||
29 | 31.08.2022 | Postal service | 437,00 | 433,00 | 4,00 | |||
30 | 04.09.2022 | Material (creative) | 160,00 | 160,00 | ||||
31 | 27.10.2022 | Entrance fee (exhibition) | 1 140,00 | 1 140,00 | ||||
32 | 28.10.2022 | Transport (bus) | 890,00 | 200,00 | 500,00 | 190,00 | ||
33 | 28.10.2022 | Services (hospital) | 80,00 | 80,00 | ||||
34 | 28.10.2022 | Entrance fee (swimming pool) | 1 670,00 | 1 670,00 | ||||
35 | 29.10.2022 | Food | 2 775,00 | 1 775,00 | 1 000,00 | |||
36 | 30.10.2022 | Food | 460,00 | 460,00 | ||||
37 | 01.11.2022 | Transport (train) | 274,00 | 274,00 | ||||
38 | 08.12.2022 | Accommodation | 6 600,00 | 2 000,00 | 4 600,00 | |||
39 | 09.12.2022 | Administrative fee | 300,00 | 300,00 | ||||
Overview (output) |
I cannot figure out, how to filter costs by its source, more precisely how to display its value in a proper position when split by source.
I have tried to implement these rules in FILTER function:
A) Is it a "single source" cost AND is in current column/source? → put one row and whole cost
Excel Formula:
(data[Source] = source_filter) * (data[Helper 3] = "")
B) Is it a "single source" cost AND is in different column/source? → put one row and whole cost
Excel Formula:
(data[Source] <> source_filter) * (data[Helper 3] = "")
C) Is it a "multi-source" cost AND in current column/source? → skip other rows and put its partial cost
Excel Formula:
(data[Source] = source_filter) * (data[Helper 3] = "YES")
D) Is it a "multi-source" cost AND in different column/source? → skip other rows and put its partial cost
Excel Formula:
(data[Source] <> source_filter) * (data[Helper 3] = "YES") * (data[Helper 4] = "YES")
Those two last rules are not working well. Problem is I would need to "pre-filter" the data, that comes to FILTER function, so the output would skip the empty lines correctly. Like add a rule something like "IF it is a multi-sourced cost AND it is in a current column/source AND has not been mentioned yet"...:
filter_costs_source_small.xlsx | |||||||||
---|---|---|---|---|---|---|---|---|---|
B | C | D | E | F | G | H | |||
1 | Choose action→ | Action 1 | |||||||
2 | |||||||||
3 | Overview of costs by source (my best attempt so far) | ||||||||
4 | Action 1 | ||||||||
5 | ...of which covered by | ||||||||
6 | Date | Item | Total cost… | Source B | Source C | Source D | |||
7 | 10.06.2022 | Material (gas) | 278,00 | 278,00 | |||||
8 | 11.06.2022 | Material (building) | 5 083,00 | 1 900,00 | 2 100,00 | 1 083,00 | |||
9 | 16.06.2022 | Material (saw blade) | 828,00 | ||||||
10 | 29.06.2022 | Material (screws) | 162,00 | 828,00 | |||||
11 | 30.06.2022 | Material (steel pot) | 4 258,00 | 162,00 | 2 000,00 | ||||
12 | 11.07.2022 | Food | 952,00 | 2 258,00 | |||||
13 | 11.07.2022 | Material (building) | 2 674,00 | 952,00 | |||||
14 | 11.07.2022 | Material (fabrics) | 755,00 | 1 100,00 | |||||
15 | 14.07.2022 | Material (plasters) | 1 080,00 | 1 574,00 | 500,00 | ||||
16 | 15.07.2022 | Services (health) | 250,00 | 755,00 | |||||
17 | 18.07.2022 | Material (pharmacy) | 198,00 | 580,00 | |||||
18 | 18.07.2022 | Food | 1 109,00 | ||||||
19 | 20.07.2022 | Services (waste fee) | 300,00 | 250,00 | 198,00 | ||||
20 | 24.07.2022 | Material (organizer, rail) | 957,00 | 200,00 | |||||
21 | 25.07.2022 | Transportation (cars) | 3 542,00 | 909,00 | 1 542,00 | ||||
22 | 25.07.2022 | Admission (swimming pool) | 886,00 | 957,00 | |||||
23 | 27.07.2022 | Material (markers) | 33,00 | 300,00 | 900,00 | 33,00 | |||
24 | 30.07.2022 | Services (water supply) | 160,00 | ||||||
25 | 1 100,00 | ||||||||
26 | |||||||||
27 | 886,00 | ||||||||
28 | |||||||||
29 | 160,00 | ||||||||
Overview (output) |
Cell Formulas | ||
---|---|---|
Range | Formula | |
B4 | B4 | =action_choice |
E6 | E6 | =IFERROR(INDEX(SORT(UNIQUE(FILTER(data[Source], data[Action] = action_choice))), 1), "") |
F6 | F6 | =IFERROR(INDEX(SORT(UNIQUE(FILTER(data[Source], data[Action] = action_choice))), 2), "") |
G6 | G6 | =IFERROR(INDEX(SORT(UNIQUE(FILTER(data[Source], data[Action] = action_choice))), 3), "") |
H6 | H6 | =IFERROR(INDEX(SORT(UNIQUE(FILTER(data[Source], data[Action] = action_choice))), 4), "") |
B7:B24 | B7 | =FILTER(data[Date], (((data[Helper 4] = "YES") * (data[Helper 3] = "YES")) + (data[Helper 2] = 0)) * (data[Action] = action_choice)) |
C7:C24 | C7 | =FILTER(data[Item], (((data[Helper 4] = "YES") * (data[Helper 3] = "YES")) + (data[Helper 2] = 0)) * (data[Action] = action_choice)) |
D7:D24 | D7 | =FILTER(data[Helper 0 (cost)], (((data[Helper 4] = "YES") * (data[Helper 3] = "YES")) + (data[Helper 2] = 0)) * (data[Action] = action_choice)) |
E7:E29,G7:G24,F7:F27 | E7 | =LET( source_filter, E6, FILTER(IF(data[Source] = source_filter, data[Cost] * -1, ""), (data[Action] = action_choice) * ( ((data[Source] = source_filter) * (data[Helper 3] = "")) + ((data[Source] <> source_filter) * (data[Helper 3] = "")) + ((data[Source] = source_filter) * (data[Helper 3] = "YES")) + ((data[Source] <> source_filter) * (data[Helper 3] = "YES") * (data[Helper 4] = "YES") ) ) ) ) |
H7:H24 | H7 | =LET( source_filter, H6, FILTER(IF(data[Source] = source_filter, data[Cost] * -1, ""), (data[Action] = "Action 1") * ( ((data[Source] = source_filter) * (data[Helper 3] = "")) + ((data[Source] <> source_filter) * (data[Helper 3] = "")) + ((data[Source] = source_filter) * (data[Helper 3] = "YES")) + ((data[Source] <> source_filter) * (data[Helper 3] = "YES") * (data[Helper 4] = "YES") ) ) ) ) |
Dynamic array formulas. |
Named Ranges | ||
---|---|---|
Name | Refers To | Cells |
action_choice | ='Overview (output)'!$C$1 | H6, F6:G7, B7:E7, E6 |
Cells with Data Validation | ||
---|---|---|
Cell | Allow | Criteria |
C1 | List | Action 1;Action 2 |
For a better view of the data you can download the whole table here:
filter_costs_source.xlsx
ulozto.net
Notes:
- I prefer spilled dynamic output and formulas due to several further reasons.
- Filter function should be universal in the sense of independence from the source.
- I can add some additional helping colums to data table, if needed. But I would rather not make any "source-sutomized" colums (like extra column for every source), if possible...
- Every cost can be financed by up to 4 sources.
- Number of different sources over the whole year is about 20, it varies over the actions.
Thank you for your ideas.