执行两个单独的 case 语句的计算
Performing calculation of two separate case statements
我在 NetSuite 中创建了一个保存的搜索,它显示了两个单独的案例语句。
1- {transaction.type} = 'Item Receipt' 和 {transaction.account} = '5505 销货成本:产品成本' 或 {transaction.type} = 'Item Fulfillment' and {transaction.account} = '5505 Cost of Goods Sold : Product Cost' then {transaction.amount} else null end
2- {transaction.type} = 'Invoice' 或 {transaction.type} = 'Cash Sale' 或 {transaction.type} = 'Cash Refund' 的情况或 {transaction.type} = 'Credit Memo' 然后 {transaction.amount} else null end
现在我需要添加第三列,在其中我可以通过将结果值除以 case case 语句 1 和 2 来显示 %。任何建议这怎么可能?谢谢!
正如 Brian 提到的(我猜你正在做的那样)分组是最简单的方法。
您可以为公式(百分比)字段使用最小值(如图所示)、最大值或平均值。
上面显示的 IN 语句也可以简化您的公式。
编辑:
要避免可能被零除的错误:
SUM(案例 when {transaction.account} = '5505 Cost of Goods Sold :Product Cost' and {transaction.type} in ('Item Fulfillment','Item Receipt') then {transaction.amount} else 0 end) / NULLIF( SUM(当 {transaction.type} in ('Invoice','Cash Sale','Cash Refund','Credit Memo') then {transaction.amount} else 0 end) ,0)
我在 NetSuite 中创建了一个保存的搜索,它显示了两个单独的案例语句。
1- {transaction.type} = 'Item Receipt' 和 {transaction.account} = '5505 销货成本:产品成本' 或 {transaction.type} = 'Item Fulfillment' and {transaction.account} = '5505 Cost of Goods Sold : Product Cost' then {transaction.amount} else null end
2- {transaction.type} = 'Invoice' 或 {transaction.type} = 'Cash Sale' 或 {transaction.type} = 'Cash Refund' 的情况或 {transaction.type} = 'Credit Memo' 然后 {transaction.amount} else null end
现在我需要添加第三列,在其中我可以通过将结果值除以 case case 语句 1 和 2 来显示 %。任何建议这怎么可能?谢谢!
正如 Brian 提到的(我猜你正在做的那样)分组是最简单的方法。
您可以为公式(百分比)字段使用最小值(如图所示)、最大值或平均值。
上面显示的 IN 语句也可以简化您的公式。
编辑:
要避免可能被零除的错误:
SUM(案例 when {transaction.account} = '5505 Cost of Goods Sold :Product Cost' and {transaction.type} in ('Item Fulfillment','Item Receipt') then {transaction.amount} else 0 end) / NULLIF( SUM(当 {transaction.type} in ('Invoice','Cash Sale','Cash Refund','Credit Memo') then {transaction.amount} else 0 end) ,0)