0

我正在尝试导出一个在数据透视表上使用 IF 语句的公式。

目标是对不存在的值执行 IF 函数。到目前为止,我有以下内容:

=IF(GETPIVOTDATA("PO Outstanding Units",$A$2,"PO Horizon",0)=0,GETPIVOTDATA("PO Outstanding Units",$A$2,"PO Horizon","Past Due"),IF(GETPIVOTDATA("PO Outstanding Units",$A$2,"PO Horizon","Past Due")=0,GETPIVOTDATA("PO Outstanding Units",$A$2,"PO Horizon",0),(GETPIVOTDATA("PO Outstanding Units",$A$2,"PO Horizon",0)+GETPIVOTDATA("PO Outstanding Units",$A$2,"PO Horizon","Past Due"))/1000))

该公式的目的是查看IF "this pivot data" DOES NOT exist,然后"Insert true value",然后IF "this DIFFERENT pivot data" DOES NOT EXIST,然后"Insert true value",最后一个错误的陈述将是if both pivot data DO exist

基本上,我如何制作一个指示数据透视表值是否存在的公式?

4

1 回答 1

1

您正在寻找查找不存在的项目的功能是ISBLANK

这将使您的示例函数如下所示:

=IF(ISBLANK(GETPIVOTDATA("PO Outstanding Units",$A$2,"PO Horizon",0)),
    GETPIVOTDATA("PO Outstanding Units",$A$2,"PO Horizon","Past Due"),
    IF(ISBLANK(GETPIVOTDATA("PO Outstanding Units",$A$2,"PO Horizon","Past Due")),
        GETPIVOTDATA("PO Outstanding Units",$A$2,"PO Horizon",0),
        (GETPIVOTDATA("PO Outstanding Units",$A$2,"PO Horizon",0)+GETPIVOTDATA("PO Outstanding Units",$A$2,"PO Horizon","Past Due"))/1000
    )
)

如果您需要检查列是否存在,则 MATCH 将检查该列,如果不存在则给出错误,因此,要测试Past Due是否是列名,然后

ISERROR(MATCH("Past Due",$A$2:$F$2,0))

如果找到该列,将返回TRUE(将 $A$2:$F$2 调整到您的数据透视列名称范围)

于 2012-11-12T20:44:20.963 回答