根据另一列的类别将总和划分到同一列
divide sum into the same column based on categories from another column
我有以下数据集:
+-----------+-----+-----------+
| date|count|steps_order|
+-----------+-----+-----------+
|2021-12-10 | 4| 2|
|2021-12-10 | 95| 2|
|2021-12-10 | 45| 4|
|2021-12-10 | 273| 4|
|2021-12-10 | 3| 4|
|2021-12-10 | 303| 1|
|2021-12-10 | 47| 1|
|2021-12-10 | 7| 1|
|2021-12-10 | 279| 3|
|2021-12-10 | 47| 3|
|2021-12-10 | 3| 3|
+-----------+-----+-----------+
我希望能够将计数列的总和除以 steps_order 1 和 2。
我试过这个:
Completion Rate =
DIVIDE(
SUM('table'[count], FILTER( 'table', 'table'[steps_order]=1)),
SUM('table'[count], FILTER( 'table', 'table'[steps_order]=2))
)
和其他类似的解决方案,但我总是遇到这个错误 The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.
这是一个衡量标准
Completion Rate =
VAR Step_1 =
CALCULATE (
SUM ( 'table'[count] ),
FILTER (
ALL ( 'table'[count] ),
'table'[count] = 1
)
)
VAR Step_2 =
CALCULATE (
SUM ( 'table'[count] ),
FILTER (
ALL ( 'table'[count] ),
'table'[count] = 2
)
)
RETURN
DIVIDE (
Step_1,
Step_2
)
假设你想创建一个measure,你可以使用下面的代码:
Completion Rate =
DIVIDE(
Calculate(SUM('table'[count]), FILTER( 'table', 'table'[steps_order]=1)),
Calculate(SUM('table'[count]), FILTER( 'table', 'table'[steps_order]=2))
)
你会得到这样的结果:
我有以下数据集:
+-----------+-----+-----------+
| date|count|steps_order|
+-----------+-----+-----------+
|2021-12-10 | 4| 2|
|2021-12-10 | 95| 2|
|2021-12-10 | 45| 4|
|2021-12-10 | 273| 4|
|2021-12-10 | 3| 4|
|2021-12-10 | 303| 1|
|2021-12-10 | 47| 1|
|2021-12-10 | 7| 1|
|2021-12-10 | 279| 3|
|2021-12-10 | 47| 3|
|2021-12-10 | 3| 3|
+-----------+-----+-----------+
我希望能够将计数列的总和除以 steps_order 1 和 2。
我试过这个:
Completion Rate =
DIVIDE(
SUM('table'[count], FILTER( 'table', 'table'[steps_order]=1)),
SUM('table'[count], FILTER( 'table', 'table'[steps_order]=2))
)
和其他类似的解决方案,但我总是遇到这个错误 The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.
这是一个衡量标准
Completion Rate =
VAR Step_1 =
CALCULATE (
SUM ( 'table'[count] ),
FILTER (
ALL ( 'table'[count] ),
'table'[count] = 1
)
)
VAR Step_2 =
CALCULATE (
SUM ( 'table'[count] ),
FILTER (
ALL ( 'table'[count] ),
'table'[count] = 2
)
)
RETURN
DIVIDE (
Step_1,
Step_2
)
假设你想创建一个measure,你可以使用下面的代码:
Completion Rate =
DIVIDE(
Calculate(SUM('table'[count]), FILTER( 'table', 'table'[steps_order]=1)),
Calculate(SUM('table'[count]), FILTER( 'table', 'table'[steps_order]=2))
)
你会得到这样的结果: