Power BI 数字格式

问题描述 投票:0回答:1

我有一个大型数据集提供了业务部门的销售数字。我编写了 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? 

感谢您的宝贵时间!

powerbi formatting dax
1个回答
0
投票

您已将

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")
    )
© www.soinside.com 2019 - 2024. All rights reserved.