Countif with Subtraction 如果 C 列有 X 作为值

Countif with Subtraction if column C has X as a value

我有一个 sheet,它是可用产品的列表。

b 列是名称,"D" 列是空白的,除非已发货,然后 "X" 被放入该框

然后在 "F" 列中,我使用 unique 获得了 B 列的值。

=sort(UNIQUE(B4:B100),1,True)

我想要的是,如果 "X" 在 "D" 列中,则从 "G"

列中的总数中减去
=COUNTIF($B:B100,G4)

https://docs.google.com/spreadsheets/d/1BeuvT3ACYYpWWhrg7UKdQe2erY_P-czA73tV6qEBzdY/edit?usp=sharing

=ARRAYFORMULA({INDEX(QUERY(B4:B, 
 "select B,count(B) where B is not null group by B label count(B)''", 0),,1), 
 QUERY(IFERROR(QUERY(B4:B, 
 "select count(B) where B is not null group by B label count(B)''", 0)-
 IFERROR(VLOOKUP(INDEX(QUERY(B4:B, 
 "select B,count(B) where B is not null group by B label count(B)''", 0),,1), QUERY(B4:D, 
 "select B,count(B) where D is not null group by B label count(B)''", 0), 2, 0))), 
 "where Col1 is not null", 0)})