Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding complex measures in MDX

Tags:

iccube

mdx

I have successfully added basic sum/count/etc.. simple measures, but have no idea how to add more complex one.

Let's assume that data structure represent tracks with goods and have next structure:

  • date
  • id_track
  • id_articte
  • amount
  • cost

And want to calculate next measures:

  1. average item price, calculated as sum(cost) / sum(amount)
  2. average track cost. It's average between sum(cost) for whole tracks. Sql expression looks like sum(cost) / count(distinct id_track)

What is the right way to add this measures to my cube, in case i will need them in Excel over XMLA?

like image 903
Oleksandr Voytsekhovskyy Avatar asked Dec 31 '25 21:12

Oleksandr Voytsekhovskyy


1 Answers

Complex calculation are solved using what we call in MDX 'calculated measures'.

Calculated Measures support the whole power of MDX language. You can see more information about Calculated Measures here. They are very powerful and over 100 functions are supported (function list).

If you want to define a calculated measure once per schema I'd advise defining them in Advanced/Scripts in the Builder UI tab. You can first check validity in the MDX IDE and once validated move them to the Script.

like image 91
ic3 Avatar answered Jan 06 '26 10:01

ic3



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!