Search code examples
mdxiccube

icCube - function calling another function results in NULL


Below the MDX statement on icCube. (Note that icCube has a non-native language component, called function).

with function article_list() as topcount([Product].[Product].[Article], [amount], 10)
function benchmark_best_index2(i) as sum(order(topcount([Product].[Product].[Article], [amount], 10), [measures].[amount], desc).(i-1) , [measures].[amount])


// why doesnot the following function work?
function benchmark_best_index(list,i) as sum(order(list, [measures].[amount], desc).(i-1), [measures].[amount])


member [measures].[bm_top_amount_doesnotwork] as benchmark_best_index(article_list(),1)
member [measures].[bm_top_amount_doesnotwork_either] as benchmark_best_index( topcount([Product].[Product].[Article], [amount], 10),1)
member [measures].[bm_top_amount_works] as benchmark_best_index2(1)

select { [measures].[amount],[measures].[bm_top_amount_doesnotwork], [measures].[bm_top_amount_doesnotwork_either], [measures].[bm_top_amount_works]} on 0
,article_list() on 1
from sales

I cannot get the calculated measure [bm_top_amount_doesnotwork] and [bm_top_amount_doesnotwork_either] to work.

My idea is to have 2 generic functions, with the 2nd one calling the first one. The end result is a benchmark value that can be used for charts, calculations and so on.

I see this is not possible form the above stated MDX. But is it possible? And if YES, how?


Solution

  • We've to check in detail what went wrong (issue) in the meantime you can force the type of the parameter so the MDX parser knows it is a set :

    sum(order( {list} , [measures].[amount], desc).(i-1), [measures].[amount])