0

See title, trying to pass a formatting selection (for example, percentage) to a Deneb visual instead of defining it in the vega / vega-lite JSON, and wanted to know if such a thing was possible.

Right now, we are just manually changing the formatting in the JSON

  • If you want to use Power BI/Excel style data formats (#,##0.00) instead of Vega/D3 style formats (.2f), you can. See https://deneb-viz.github.io/formatting#power-bi-custom-formatter. Maybe you could do something with that, but I think I’d still lean towards passing a formatted string for labels. – TheRizza Feb 02 '23 at 02:28

1 Answers1

0

No, but Kerry Kolosko has a clever solution for this in her KPI charts that are in the sample file for the Deneb visual. In addition to passing in number fields, she also does formatting in DAX and passes in text to use with text marks.

DAX

Format Variance = 
var a = calculate(DIVIDE(MAX('KPIsDATA'[Actual]),'KPITarget'[KPITarget Value])-1,'KPIsDATA'[Date]=MAX('KPIsDATA'[Date]))
var b = FORMAT(ABS(a),"#%")
Var c = IF(a>0,"▲ " , "▼ ")
Var d = IF(a>0," above target" , " below target")
Return
c & b & d

Dataset

You could do an "Auto" format like this in DAX:

Format Actual = 
VAR _number = SUM(KPIsDATA[Actual])
VAR _digits = 1
RETURN IF( ABS(_number) >= 1000000000, FORMAT(_number, "0,,," & IF(_digits > 0, ".", "") & REPT("0",_digits) & "B"),
           IF( ABS(_number) >= 1000000, FORMAT(_number, "0,," & IF(_digits > 0, ".", "") & REPT("0",_digits) & "M"),
               IF( ABS(_number) >= 1000, FORMAT(_number, "0," & IF(_digits > 0, ".", "") & REPT("0",_digits) & "K"),           
                   FORMAT(_number, "0" & IF(_digits > 0, ".", "") & REPT("0",_digits) )
               )
           )
       )
TheRizza
  • 1,577
  • 1
  • 10
  • 23