Hello gooddata team, We have clients across the r...
# gooddata-ui
k
Hello gooddata team, We have clients across the region & we want to support multiple currencies in the dashboard & insights. What’s the best way to do it?
j
Hi Kovil, although this is not straightforward, it is possible to use M:N relation to map facts in fact dataset in single currency to different currencies. Bridge table which implements mapping between source currency and target currency may contain foreign currency exchange range which can be used in MAQL formula to convert data from fact table in source currency to target currency. Adding target currency attribute into a report would lead to data duplication and data would be displayed in multiple currencies. This can be combined with data permissions to filter data for the user and display only single target currency. Another option is to store data in fact table redundantly in multiple currencies without M:N relation in data model and use data permission to filter data in given currency for the user. An option can be also to replace data permission with some mandatory filter in UI which would filter always single currency. This can be probably implemented in some custom UI and selection of the currency can be then sent as one of the filters of executed insights/dashboards. You may also consider using of custom dashboard plugin and render custom table with reordered columns or merged value with currency. In edit mode of the table you would see currency and value as separate columns but users of dashboard would see them formatted according to your needs. see https://www.gooddata.com/docs/gooddata-ui/latest/references/dashboard_component/dashboard_plugins_api/ Although the dashboard plugin is another workaround, I am afraid that I do not have a working example of this as plugins cover a wide range of use cases, but you may consider it as the optimal solution. If you are interested in reading further, this question was also raised in our Slack Community where one of our engineers step in with some workarounds: https://gooddataconnect.slack.com/archives/C01USCF4S10/p1654090749547249
k
Can it be done via Frontend using custom css or using some format option?
Basically we are using insight view component - our backend knows the currency of the client & it can supply that so if frontend when displaying the visualisation can handle currency it would be the best approach for us.
We don’t need to convert currencies - we store values as INT & currency separately. Ex - we have a currency table Region | Country | Currency We have our sales table Amount | Amount Paid | Refund the above are stored as INT values. If I concat currency with the INT values then wouldn’t gooddata recognise it as String? If this happens then my comparison metrics will take a hit.
j
k
Can I do it programmatically via an API or do I have to it for all clients manually
j
It is possible to set formatting via API: https://www.gooddata.com/docs/cloud/create-metrics/format-numbers/#format-metric-numbers-through-the-api But note that the formatting is only applicable to metrics, not raw facts.
k
How is metric different from facts? Also, whenever I provision a workspace or a child workspace I need to do this? Are there any examples for this?
We are using insights right now for revenue
Is this a possible way to do it ?
Copy code
import { modifyMeasure, newMeasure } from "@gooddata/sdk-model";
import { InsightView } from "@gooddata/sdk-ui-ext";

// Assuming you have insight with dynamic currency measure
const currencySymbol = "₹";

const formattedMeasure = modifyMeasure("measure_id", (m) =>
  m.format(`[${currencySymbol}]#,##0.00`)
);

const modifiedInsight = insightModifyMeasures(insight, [formattedMeasure]);

<InsightView
  insight={modifiedInsight}
  backend={backend}
  workspace={workspaceId}
/>;
j
Hi Kovil, A fact is a logical object that represents a numerical piece of data, which in business environments are used to measure business processes. A metric is a computational expression of numerical data (facts or other metrics). For example, you can have metrics representing the average invoice sum or the number of sold items per country. You can also create metrics from attributes to count the number of individual values of the attribute. For example, if you have an attribute describing the location of a sales department, you may want to know how many different locations you have in total. Metrics are built using Multi-Dimension Analytical Query Language (MAQL) through either the API or the Metric Editor. In GoodData, you work with the metrics in Analytical Designer when creating visualizations.
Your example seems to be correct here. Are you facing any errors/issues?
k
Yeah, we tried it with insight view but it didn’t work- we are using referential component & not programmatic. Should we share some code examples for this? CC : @Ayush Kumar
j
yes please, code example would be great
k
@Ayush Kumar -can you share pls
m
Hi Kovil and @Ayush Kumar we are still waiting for some (code) example.