Using String Array in Metric Cards

Hi,

I am trying to use string array in metric cards. However, I was not able to find a way to display it.

  • Metric Card widget is expecting a string variable.
  • I tried to convert the string array to a string via “variable transformation” but I was not able to find a way to do it.

Bottom-line is, how can I display a string array property of an object in metric cards?

Thanks,
Baris

There is currently no way to create a string variable from a string array using variable transforms. You could use a function backed string variable: https://www.palantir.com/docs/foundry/workshop/functions-use/#function-backed-variables-in-workshop

Hello!

If your object has a property of type array of strings the following solution will work:

  1. Create a string array variable in workshop and set it to an object property (use the object you are wanting to use in your metric card).

  2. Create a new code repository and write a Typescript function with input type as array of strings and output type as string. This function should loop and concatenate each of the strings with a separator/format of your choice and then return the concatenation of type string. Publish the function.

  3. Create a new string variable in workshop and select “function”. Choose the function you just published and then choose the string array variable you created in step 1 as the input. The output should be a string which you can display in a metric card.

Nicole