我试图推导出一个在数据透视表上使用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
。
基本上,我如何制作一个表明是否存在数据透视表值的公式?
答案 0 :(得分: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会检查它,如果它不存在则给出错误,因此,要测试过期是否是列名,那么
ISERROR(MATCH("Past Due",$A$2:$F$2,0))
如果列未,将返回 TRUE (调整$ A $ 2:$ F $ 2到您的数据透视表列名称范围)