我有一个大型数据集提供了业务部门的销售数字。我编写了 dax,当销售人员深入研究数据集时,它将格式化数字。其金额从数十亿到数千不等。这是 DAX 指数:
Act - Plan =
var CurrentValue = ABS(
CALCULATE(
SUM(DataBase[Value]),
DataBase[Measure] = "Revenue (Projected)",
DataBase[Period] = "CY Actual"
)+CALCULATE(
SUM(DataBase[Value]),
DataBase[Measure] = "Open Order $s",
DataBase[Period] = "CY Actual"
)-CALCULATE(
SUM(DataBase[Value]),
DataBase[Measure] = "Revenue (Projected)",
DataBase[Period] = "Baseforecast")
)
Return
Switch (
true (),
CurrentValue <= 1E3, FORMAT ( CurrentValue, "#,0.00" ),
CurrentValue <= 1E6, FORMAT ( CurrentValue, "#,0,.00 K" ),
CurrentValue <= 1E9, FORMAT ( CurrentValue, "#,0,,.00 M"),
FORMAT ( CurrentValue, "#,0,,,.00 B")
)
The issue that I am running in is that the formatted value will not show negative (1-2=1).
what should I include to be able to reflect the proper value?
感谢您的宝贵时间!
您已将
ABS
包装为 CurrentValue
,这就是您要输出的内容,因此始终为正值。
试试这个:
Act - Plan =
var CurrentValue =
CALCULATE(
SUM(DataBase[Value]),
DataBase[Measure] = "Revenue (Projected)",
DataBase[Period] = "CY Actual"
)+CALCULATE(
SUM(DataBase[Value]),
DataBase[Measure] = "Open Order $s",
DataBase[Period] = "CY Actual"
)-CALCULATE(
SUM(DataBase[Value]),
DataBase[Measure] = "Revenue (Projected)",
DataBase[Period] = "Baseforecast")
)
var absValue = ABS(CurrentValue)
Return
Switch (
true (),
absValue <= 1E3, FORMAT ( CurrentValue, "#,0.00" ),
absValue <= 1E6, FORMAT ( CurrentValue, "#,0,.00 K" ),
absValue <= 1E9, FORMAT ( CurrentValue, "#,0,,.00 M"),
FORMAT ( CurrentValue, "#,0,,,.00 B")
)