Use global variables in a Dashboard

Solved!
LouisDeville
Level 1
Use global variables in a Dashboard

Hi, 

I am using a table from a dataset to make a dashboard and I want to show on it 3 things that are in global variables :

- The datasource name; 

- The table name; 

- The date the data was retrieve;

I wanted to do it using global varibles. However I don't know if it is even possible to do it so. 

If there is an other way to do it (except adding an other column in my dataset because I have already 68 columns and more thant 200k rows) I'd be happy to read a better one.

 

Thanks !

 

 

0 Kudos
1 Solution
SarinaS
Dataiker

Hi @LouisDeville,

Indeed unfortunately there isn't a way to display variables on a dashboard. 

You can however display dataset Metrics on dashboards, which is likely the approach that makes the most sense here. Dataset metrics are found and configured in the dataset "Status" tab. The build date is one of the default metrics that is already computed. 

For the table name and datasource name, you can create new Python probe metrics that simply return the value of your global variable. 

Here's an example of returning a global variable named 'test' within a Python probe:

import dataiku 
# Define here a function that returns the metric.
def process(dataset, partition_id):
    # here 'test' is the name of my variable
    globalvar = dataiku.get_custom_variables()['test']
    return {'globalvar' : globalvar}

 

Screenshot 2023-06-02 at 5.31.58 PM.png

To publish any metrics, you can do so directly from the metrics screen, or from the Dashboard > + Metrics selection. 

Screenshot 2023-06-02 at 5.32.16 PM.png

I hope that's helpful, please let us know if you have any questions about this!

Thank you,
Sarina

View solution in original post

2 Replies
SarinaS
Dataiker

Hi @LouisDeville,

Indeed unfortunately there isn't a way to display variables on a dashboard. 

You can however display dataset Metrics on dashboards, which is likely the approach that makes the most sense here. Dataset metrics are found and configured in the dataset "Status" tab. The build date is one of the default metrics that is already computed. 

For the table name and datasource name, you can create new Python probe metrics that simply return the value of your global variable. 

Here's an example of returning a global variable named 'test' within a Python probe:

import dataiku 
# Define here a function that returns the metric.
def process(dataset, partition_id):
    # here 'test' is the name of my variable
    globalvar = dataiku.get_custom_variables()['test']
    return {'globalvar' : globalvar}

 

Screenshot 2023-06-02 at 5.31.58 PM.png

To publish any metrics, you can do so directly from the metrics screen, or from the Dashboard > + Metrics selection. 

Screenshot 2023-06-02 at 5.32.16 PM.png

I hope that's helpful, please let us know if you have any questions about this!

Thank you,
Sarina

LouisDeville
Level 1
Author

Hello Sarina,

Thank you very much for your reply. Unfortunately, I can't test it at the moment, but it seems to work very well!

I hope it will be useful to others ๐Ÿ™‚

 

Louis