Hello, For created metrics, is there a way that I ...
# gooddata-cn
a
Hello, For created metrics, is there a way that I can create a metric that does not require the primary key of the table referenced to be used in the insight? For example, suppose I have a dataset like this: ā€¢ PositionKey, AccountId, Cusip, Units In this example, units is the metric, PositionKey is the primary Key. If I create a metric (ex: Select Units / 100.00), and want to use it in an insight, it will give me an error unless I add PositionKey to that insight. Using GD.CN 1.7 for reference, but have also found this in the GD SaaS version.
It does appear if I use an aggregation metric that I can add it without adding the key. However any arithmetic metrics have this same issue. I would have thought that these created metrics would function the same way as a metric that is in the dataset. (For example, just adding the metric it automatically sums the metric together.)
j
We need to see your model. Please, expand the Units metric and show us in which datasets related entities (facts, attributes) are stored.
j
Units in your model is a fact and not metric. You need to add aggregation function to your MAQL formula if you put it into insight without PositionKey. I see that you want to sum the facts from what you have written above. Proper formula for this is:
Copy code
select sum({fact/units})/100.00
Please note that SUM aggregation function is used if you drag a fact from catalog in Analyze and drop it into Metric bucket in insight configuration. This function can be changed to other functions. When you write a MAQL formula you have to use the aggregation function as well to tell the query engine how to reduce many facts in the dataset into a single number. This is needed also if you slice the metric by other attribute like AccountId because there can be many facts for one AccountId in the data. The aggregation function is not needed only if you display the fact with granularity of dataset.
šŸ™Œ 1
p
šŸŽ‰ New note created.
a
Thanks Jakub and Jan! Jakub, that did the trick, thanks again!