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.:
thanks for your replies! I tried to implement the steps, in several ways. I didn't get it to work unfortunately.
The sample data is simple, because I created some dummy data.
I have a table with a column called Percentage. It has the following data (see below).
The measure, which I added to the Deneb visual is
| 0,01 |
| 0,1 |
| 0,25 |
| 0,5 |
| 0,75 |
| 0,99 |
1 |
- dm-p2 years ago
Super User
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
- Anonymous2 years agoNot applicable
thank you so much!! I really appreciate your help!
- Modify my suggestion to multiply by 100 to get a number between 1 and 100 rather than 0 and 1, e.g.: