我们如何在切换和格式化功能中分配前缀字符

时间:2018-09-27 04:09:49

标签: powerbi dax

我想知道如何在保留两位小数的同时向格式功能添加字符

它何时运行完美

Measure = SWITCH(SELECTEDVALUE(Table[Country]),
          "EUR", FORMAT(SUM(Table[Sales]), "€0.00"),
          "US",  FORMAT(SUM(Table[Sales]), "$0.00"),
          "UK",  FORMAT(SUM(Table[Sales]), "£0.00"))

但是,我想在其中添加一个字符,它超出了当前范围。

Measure = SWITCH(SELECTEDVALUE(Table[Country]),
          "EUR", FORMAT(SUM(Table[Sales]), "EUR0.00"),
          "US",  FORMAT(SUM(Table[Sales]), "USD0.00"),
          "UK",  FORMAT(SUM(Table[Sales]), "UK0.00"))

此外,DAX函数仅允许某些字符,例如

 Measure = SWITCH(SELECTEDVALUE(Table[Country]),
          "EUR", FORMAT(SUM(Table[Sales]), "ppppp0.00"),    it works
          "US",  FORMAT(SUM(Table[Sales]), "h0.00"),      doesn't work
          "UK",  FORMAT(SUM(Table[Sales]), "l0.00"))         it works

大家知道这是怎么发生的吗?

谢谢

1 个答案:

答案 0 :(得分:0)

以下方法应该起作用:

Measure = SWITCH(SELECTEDVALUE(Table[Country]),
      "EUR", FORMAT(SUM(Table[Sales]), "EUR" & "0.00"),
      "US",  FORMAT(SUM(Table[Sales]), """USD""" & "0.00"),
      "UK",  FORMAT(SUM(Table[Sales]), "UK" & "0.00"))