It is possible but I don't know how well it will hold up or what might break it. Below is a rough idea. It can probably be cleaned up and made better but it shows a way to do it. A more robust way would be to have a checkbox to switch the chart vs what I did in Table 3 that looks for a cell that is only there when categories is on.


Create Table 2 with categories OFF on Table 1
Columns A and C are text, not formulas. Fill in blank rows with two dashes, --
B2 =SUMIF(Table 1::A,A2,Table 1::C)
D2 =XLOOKUP(C2,Table 1::B,Table 1::C,"",0)
Fill down with both to complete those columns
I am assuming Table 1 has only one entry for each country so it is a simple lookup to get the value.
Create Table 3 with Categories ON on Table 1
In the screenshots there is a filter on Table 3. Make the table the same number of rows as Table 2
A1 =IFERROR(IF(Table 1::$B $PARTIAL (No Summary)="",TRUE,""),FALSE)
A2 =IF(A$1,Table 2::A2,Table 2::C2)&""
B2 =IF(A$1,Table 2::B,Table 2::D)
Fill down to last row with A2 and B2 to complete the columns
Create your pie chart using all data rows in this table, including all the rows with dashes.
Put a filter on Table 3 to "show rows where text is not --"
The pie chart should ignore all the "--" rows by default (it is a setting in the Chart format)