在 Data Studio 中使用 2 个指标的 Case Statement Issue

Case Statement Issue using 2 Metrics in Data Studio

我有一个使用 2 个数字的 case 语句,但是,我得到了错误;

"an expression can have either metrics, or dimensions, but not both".

不确定这里发生了什么。

我的案例陈述如下;

Case When Num1 > 0 then Price else 0 End

数字 1 是一个整数值。 价格是一个计算值 Spent/Num1

我这样做的原因是为了避免 "No Data" 框并只显示 0。

看看this:

While useful, CASE has a significant limitation: it can't mix dimensions and metrics in the same statement. If you try, you'll get an error in Data Studio saying, "An expression can have either metrics, or dimensions, but not both."

我怀疑您可能将 Num1 作为 Dimension and Price as Metric,反之亦然。

我创建了一个简单的 table,您的案例陈述对我有用。在这里,我有 Num1PriceSpent 作为维度。