MDX for comparative analysis

Source: Internet
Author: User

In all examples, the month parameter points to the month granularity and the year parameter points to the year granularity. Date hierarchy: Year, quarter, month, and day

1. same period last year: If the query month is 200905, this indicator is 200805.
Total ([amount] within set parallelPeriod ([date]. [Date hierarchy]. [year], 1, [date]. [Date hierarchy]. [month]->? Mon ?))
2. Total for this year: If the query month is 200905, this indicator is generated during the period from 200901-200905.
Total ([amount] within set periodsToDate ([date]. [date hierarchy]. [year], [date]. [date hierarchy]. [month]->? Mon ?))

3. Total for the same period last year: If the query month is 200905, this indicator occurred during the period from.
Total ([amount] within set periodsToDate ([date]. [Date hierarchy]. [year], parallelPeriod ([date]. [Date hierarchy]. [year], 1, [date]. [Date hierarchy]. [month]->? Mon ?)))
Year-on-year growth (by date)
([Sales amount]-value (tuple (parallelPeriod ([ARPD-Sale]. [date]. [date]. [year]), [sales amount])/value (tuple (parallelPeriod ([ARPD-Sale]. [date]. [date]. [year]), [sales amount])
Period-over-period growth (by date)
([Sales amount]-value (tuple (prevMember (currentMember ([ARPD-Sale]. [date]. [date]), [sales amount])/value (tuple (prevMember (currentMember ([ARPD-Sale]. [date]. [date]), [sales amount]) 4. cumulative occurrence in history: the query month is 200805, which occurs from the time when the first node ends 200805

1) if you are prompted to use [date]. [date hierarchy]. [month]. [month-Key]
Total ([amount] within set
Filter (
Members ([date]. [date hierarchy]. [month]),
[Date]. [date hierarchy]. [month]. [month-Key] <=? Month?
))

2) If you are prompted to use [date]. [date hierarchy]. [month]
Total ([amount] within set
Lastperiods (1000, [date]. [date hierarchy]. [month]->? Month ?)) 5. the query granularity is one year. statistics are collected in the first half and second half of the year.
Balance in the first half of the year (instant indicator ):
Total ([balance] within set subset (descendants ([date]. [date hierarchy]. [year]->? Year ?, [Date]. [date hierarchy]. [month]), 5, 1 ))
Amount generated in the first half of the year (Real-Time metrics ):
Total ([amount] within set subset (descendants ([date]. [date hierarchy]. [year]->? Year ?, [Date]. [date hierarchy]. [month ))

Here, the subset () function is similar to substring (), except that subset intercepts some Members in a set (set). Note that the first subset () function is 0 rather than 1, this is similar to array.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.