Power BI DAX - 运行 计算列的 MEDIAN 或 MEDIANX 公式给出错误消息

Power BI DAX - Running the MEDIAN or MEDIANX formula for a calculated column gives error message

我一直在尝试使用 MEDIAN 公式在 Power BI Desktop 中生成一个计算列以获得中位年龄。我检查了 Age 列中是否存在文本数据或空白数据等不一致,但没有发现任何此类实例。报错信息如下-

Expressions that yield variant data-type cannot be used to define calculated columns.

分析中使用的数据托管在 data.world

非常感谢任何帮助。

这是一个很奇怪的情况,但我想我在 Microsoft Community Forum 上找到了解释。

When the underlying column is of data type Whole Number, MEDIAN function returns a variant data type because it may return a Whole Number when there is no interpolation or a Decimal Number when there is interpolation. While measures can be of variant data type, calculated columns must be of a single data type, hence the error. To force MEDIAN to always return Decimal Number, change the expression to MEDIANX(Table1, [Column2] * 1.0).

另一个修复方法是将 Age 列转换为小数类型而不是整数类型。我还发现用 VALUE 包装也行。