When attempting to use numeric formatting in Metric Card widgets, the option to use a Reference variable/property does not seem to work:
Regardless of the search typed into the filter, there are no variables or properties that appear.
When attempting to use numeric formatting in Metric Card widgets, the option to use a Reference variable/property does not seem to work:
Regardless of the search typed into the filter, there are no variables or properties that appear.
Hey @jstewartNS thanks for flagging, The option to reference a property for numeric formatting in a Metric Card is not supported at the moment. I have merged a change to remove this option to prevent any confusion moving forward.
As a workaround you can use variable transforms to construct your formatted currency variable and display that in the metric card
@mskrobola thank you for removing the option, but the workaround doesn’t replicate the same behaviour as the Reference option like is seen in OMA. I want to be able to dynamically identify the currency that is used and present the correct symbol in the numeric formatting.
I could do this with a case statement in the variable transformations, but this becomes unwieldy pretty quickly when there are many currencies we are attempting to cater for.
Hi @jstewartNS, I’ve faced a similar issue in the past and can provide some high-level design thinking that might assist, if you haven’t solved it already.
I’m unsure how your data is structured. For the following, I’ll assume your object type has one property which is revenue amount (from your screenshot) and another column that states the currency it belongs to. However, note that this could be expanded upon to suit other scenarios as well.
In workshop, you do the aggregation (variable name: amount) and can get the currency code as a string (variable name: currency), then you can input those to a Typescript function and return the amount as a formatted string:
@Function()
public formatCurrency(amount: Double, currency: string): string {
return new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(amount);
}
This is the simplest workaround to the reference not working for displaying it on a metric card, and if you have to display simultaneously multiple metric cards with amounts on multiple currencies, you can call the function several times as needed.
Example output in code preview:
Hope this helps!