Statistics of any time period

Source: Internet
Author: User
Statistics
If the query time period is a member of the dimension, then the sum of the amount of this period of time can be directly derived! (By default, the members in the dimension are by level
Totals, such as queries for a 1997-year or March 1997 rollup, you can use the following statement:
Select
{[Time2]. [1997]} on columns,
{[Customers]. [Country].members} on Rows
From Sales
where ([measures].[ Store Sales])
or [TIME]. [1997]. [Q1]. [3]
But in many cases, customers want to get a summary of any time period! Typically, we can do this:
such as: 1997.1.8--1997.5.13
With member [Time2]. [1997.1.8--1997.5.13] as ' sum ([time2].[ 1997]. [Q1]. [1]. [8]:[time2]. [1997]. [Q2]. [5]. [13]) '
Select
{[Time2]. [1997.1.8--1997.5.13]} On columns,
{[Customers]. [Country].members} on Rows
From Sales
where ([measures].[ Store Sales])

Note:
1 The start and end dates of the time period must be of the same level;
2 The unknown system will optimize the query, so use aggregation as much as possible: if 1997.1.8--1997.5.13 can be decomposed into:
SUM ([time2].[ 1997]. [Q1]. [1]. [8]:[time2]. [1997]. [Q1]. [1]. [31]) +
SUM ([time2].[ 1997]. [Q1]. [2]:[time2]. [1997]. [Q1]. [3]) +
[Time2]. [1997]. [Q2]. [4]+
SUM ([time2].[ 1997]. [Q2]. [5]. [1]:[time2]. [1997]. [Q2]. [5]. [13])
Segments are optimized as much as possible and can be used for subtraction!!
Such as:
SUM ([time2].[ 1997]. [Q1]:[time2]. [1997]. [Q2]) -
SUM ([time2].[ 1997]. [Q1]. [1]. [1]:[time2]. [1997]. [Q1]. [1]. [7]) -
SUM ([time2].[ 1997]. [Q2]. [5]. [14]:[time2]. [1997]. [Q2]. [6]. [30])

Above personal opinion, only for reference!





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.