I saw in a qlikview example "whats new in qlikview 11" that you could create "slect one metric" for sales, quantity, margin...etc..
The way they did it:
LOAD * INLINE [_metricsNo, _metrics
_metrics as _metricPickOne
My question is, if I wanted to sum up sales in a expression but don´t want to hardcode sum(sales) but instead wanted to use the Metrics Options, how do I do that? I tried sum(_metricPickOne) but that didn´t work.
I know I can use condition and say _metricPickOne = 'sales' than sum(sales) but what if I have more than 10 metrics? Is there another way?
The safest way to code this would be to use minstring() instead of only(). This way, no selection will still work and it will also protect against losing the one and only one selection (which I would recommend) on _metrics. sum($(=minstring(_metrics)))
sum($(=minstring(_metrics))) will work but the problem is you well always get the same number no matter whether you choose sales, Qty, Margin or Margin%. Thats because minstring(_metrics) always returns Margin