如何使动态 table 显示不在 sheet 中但可能是变量结果的值?

How can I make a dynamic table display a value that isn't in the sheet, but its a possible outcome for the variable?

假设我在 Google 张中有一个 table 2x2:

variable_1 variable_2
x 10
y 13
x 7
z 11

A Dynamic Table with with variable_1 in the lines and the sum(variable_2) 作为一个值,我会得到以下 table:

variable_1 sum(variable_2)
x 17
y 13
z 11

现在假设第一列是定性变量,具有以下可能的结果:x、y、z 或 w。 有没有一种方法可以在我创建动态 Table 时显示值为 0 的“w”结果?

在 R 中,我会将 variable_1 定义为一个因素,并且自动地,分组将包括“w”。 我需要得到以下 table:

variable_1 sum(variable_2)
x 17
y 13
z 11
w 0

尝试:

=INDEX(IF(D2:D="",,IFNA(VLOOKUP(D2:D, QUERY(A1:B, 
 "select A,sum(B) group by A label sum(B)''"), 2, 0), 0)))