Forum Discussion
Making Deneb dynamic
- 2 years ago
I added the data to the model and set it as a percentage type. The same with the measure.
The key thing is that percentages will be added to a Deneb visual as a decimal value, so to make this work with the template, you will need to:
- Modify my suggestion to multiply by 100 to get a number between 1 and 100 rather than 0 and 1, e.g.:
{
"name": "percent",
"update": "data('dataset')[0]['_Percentage'] * 100"
} - Because this might result in a floating point value with many decimal places, modify the text mark's text property to use a format function call to fix it to 2 decimal places, e.g.:
{
"type": "text",
"data": [{}],
"encode": {
"update": {
"text": {
"signal": "format(percent, '.2f') + '%'"
},
...
}
Note that these are minimal changes against the original template. If you have a format string against your model, you could probably use the technique in step 1 to get the _Percentage__format field that Deneb creates for measures into an additional signal and substitute that into step 2 rather than do the formating work manually, or use the pbiFormat function in Deneb to use a Power BI format string. However the above approach will work as you intend it to:
I've added this to a report and attached it so you can confirm it works and investigate the solution yourself. Changes are on lines 14 and 175 of the specification.
Regards,
Daniel
- Modify my suggestion to multiply by 100 to get a number between 1 and 100 rather than 0 and 1, e.g.:
Hi Anonymous,
Replace line 13 with the following:
{
"name": "percent",
"update": "data('dataset')[0]['_Percentage']"
}
This requests the value of the _Percentage measure in the first row of the dataset that Deneb creates.
Ref: Vega data() function
Ref: how Deneb assigns the internal dataset
Regards,
Daniel