Set variable based on another

I am looking to set a variable without user interaction based on another variable.

I have a variable where the user chooses the device. “device - sn”.

But i would like to automatically set another var for the SN that other linked dashboards will use that is only going to be the sn.

I was thinking of defining a var thats a regex of an existing one, but could not see how to do that.

Is there a way i can do that?

can you show your code? i dont understand it

For example i have a var that is used for a panel to repeat, and that further pushes to a detail panel via a link with the var being passed. That var is a query to the influxdb to populate it:

show tag values from dellsc_san_disks with key="hostname"

With results like: array1 - 111111 array2 - 22222 array3 - 33333. Thats a format of “Name - SerialNumber”

On the detail dashboard i have to use a different datasource (mssql) that requires only the SN, rather than the name being passed. So i would like to have a var named SN on that dashboard that could be just the SN part of the name and would be defined on dashboard load. Thats why i thought if i could use the regex of the var value and set that to a new var named SN the details dashboard would have it available to use with no user input. Other wise i think i am left forcing the user to select the SN on the details dashboard.

can yu make image ? soory to much text

I ended up doing this with a chain variable and using the regex of /\s\S*\s(.*)/gm

why you asked then ?

I asked because i did not know how to do it. But i did continue to research, and wanted to share the solution i had , in case it could help others.

1 Like

but me and others were researching all the waste time

Could you show me more detail like capture screen?

This topic was automatically closed after 365 days. New replies are no longer allowed.