Passing value from metric set to data cube

Hi,

I’ve a data cube with a “Python Data Generation” node that calls an api, what I need to do is pass a value to the “Python Data Generation” that will be passed to the api call as a parameter. The “Python Data Generation” script is:

import requests
import json
import datetime

from pandas.io.json import json_normalize

url = ‘http://pedroccpimenta.somee.com/sciame/consumodia.asp?CPE=’ + $local$
res = requests.get(url)
json_content = json.loads(res.text)
df = json_normalize(json_content[‘dados’])
df[‘data’] = df[‘dia’].apply(lambda x: datetime.datetime.fromtimestamp(int(x)).date())
df = df.drop([‘dia’], axis=1)
return df

The $local$ is a placeholder connected to a bridge parameter.
I’ve a dashboard with a visualization that uses the data cube with the “Python Data Generation” and another that has all the possible values for the $local$. Given this, I need to create a filter interaction that will pass the selected element to the underlying data cube (the one that has the “Python Data Generation”) to the $local$ placeholder to filter the api return based on the selected element.

PS: The visualization that has all the possible values for $local$ comes from another data cube.

How can I achieve this?

Thanks,
Luis Silva

I think you can achieve this with a data input block. I think this is the link I used to set mine up a while back. Basically you’ll drop a data input block into that data cube and feed it into the python dg block.

https://www.dundas.com/support/learning/documentation/analyze-data/setting-up-data-input

Hey, you can use the placeholder option for $local$. You can then set bridge parameter to pass a single hierarchy member or collection. I believe, it should work.

1 Like

Hi Upasana,

Yes, it worked! :slight_smile:

Thanks

1 Like