Forum Discussion
Create a digital clock in power bi desktop
- Anonymous3 years ago
Hi hb0135 ,
You can get Deneb visual in "Get more visual" .
2. Click Visual, feel free to put in a field, and click Edit:
3. Copy the following code in:
4. Copy the following code in:
{ "$schema": "https://vega.github.io/schema/vega/v5.json", "description": "A simple digital clock visualization showing the current date and time.", "width": "container", "height": "container", "autosize": {"type": "fit", "contains": "padding"}, "signals": [ { "name": "currentDate", "init": "now()", "on": [{"events": {"type": "timer", "throttle": 1000}, "update": "now()"}] }, { "name": "currentYear", "init": "year(currentDate)", "on": [ { "events": {"signal": "currentDate"}, "update": "year(currentDate)" } ] }, { "name": "currentMonth", "init": "month(currentDate)+1", "on": [ { "events": {"signal": "currentDate"}, "update": "month(currentDate)+1" } ] }, { "name": "currentDay", "init": "date(currentDate)", "on": [ { "events": {"signal": "currentDate"}, "update": "date(currentDate)" } ] }, { "name": "currentHour", "init": "hours(currentDate)", "on": [ { "events": {"signal": "currentDate"}, "update": "hours(currentDate)" } ] }, { "name": "currentMinute", "init": "minutes(currentDate)", "on": [ { "events": {"signal": "currentDate"}, "update": "minutes(currentDate)" } ] }, { "name": "currentSecond", "init": "seconds(currentDate)", "on": [ {"events": {"signal": "currentDate"}, "update": "seconds(currentDate)"} ] }, { "name": "fontSize", "value": 24, "on": [ { "events": {"type": "resize"}, "update": "min(width, height) / 20" } ] } ], "marks": [ { "type": "text", "encode": { "enter": { "x": {"signal": "width / 2"}, "y": {"signal": "height / 2"}, "align": {"value": "center"}, "baseline": {"value": "middle"} }, "update": { "text": { "signal": "format(currentYear, '04') + '-' + format(currentMonth, '02') + '-' + format(currentDay, '02') + ' ' + format(currentHour, '02') + ':' + format(currentMinute, '02') + ':' + format(currentSecond, '02')" }, "fontSize": {"signal": "fontSize"} } } } ] }5. Click Apply -- a text box with a real-time clock will be automatically generated
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi hb0135 ,
You can get Deneb visual in "Get more visual" .
2. Click Visual, feel free to put in a field, and click Edit:
3. Copy the following code in:
4. Copy the following code in:
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A simple digital clock visualization showing the current date and time.",
"width": "container",
"height": "container",
"autosize": {"type": "fit", "contains": "padding"},
"signals": [
{
"name": "currentDate",
"init": "now()",
"on": [{"events": {"type": "timer", "throttle": 1000}, "update": "now()"}]
},
{
"name": "currentYear",
"init": "year(currentDate)",
"on": [
{
"events": {"signal": "currentDate"},
"update": "year(currentDate)"
}
]
},
{
"name": "currentMonth",
"init": "month(currentDate)+1",
"on": [
{
"events": {"signal": "currentDate"},
"update": "month(currentDate)+1"
}
]
},
{
"name": "currentDay",
"init": "date(currentDate)",
"on": [
{
"events": {"signal": "currentDate"},
"update": "date(currentDate)"
}
]
},
{
"name": "currentHour",
"init": "hours(currentDate)",
"on": [
{
"events": {"signal": "currentDate"},
"update": "hours(currentDate)"
}
]
},
{
"name": "currentMinute",
"init": "minutes(currentDate)",
"on": [
{
"events": {"signal": "currentDate"},
"update": "minutes(currentDate)"
}
]
},
{
"name": "currentSecond",
"init": "seconds(currentDate)",
"on": [
{"events": {"signal": "currentDate"}, "update": "seconds(currentDate)"}
]
},
{
"name": "fontSize",
"value": 24,
"on": [
{
"events": {"type": "resize"},
"update": "min(width, height) / 20"
}
]
}
],
"marks": [
{
"type": "text",
"encode": {
"enter": {
"x": {"signal": "width / 2"},
"y": {"signal": "height / 2"},
"align": {"value": "center"},
"baseline": {"value": "middle"}
},
"update": {
"text": {
"signal": "format(currentYear, '04') + '-' + format(currentMonth, '02') + '-' + format(currentDay, '02') + ' ' + format(currentHour, '02') + ':' + format(currentMinute, '02') + ':' + format(currentSecond, '02')"
},
"fontSize": {"signal": "fontSize"}
}
}
}
]
}
5. Click Apply -- a text box with a real-time clock will be automatically generated
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
How can I get a different time zone for this, I am trying to have five different clocks showing time for Hawaii, Pacific time zone, Mountain time zone, Central time zone, and Eastern time zone.