简体   繁体   中英

SSAS Calculated Member - How do I aggregate a measure across multiple dimensions?

I have a very simple cube that includes calculated members for various call center phone stats by date/30-minute interval. The goal is to show performance over time while highlighting potential problem areas. Specifically I'm showing the average speed of answer for each day of the month (which works beautifully) but I can't figure out how to also show the maximum answer speed during a given day (from all intervals). For example, one day might have an average speed of answer of 2:44, but since there is a single bad interval in which the speed of answer was 10:26 I want to show only that interval's value along with the average for performance comparison.

What I'm trying to get is:

Date: 2015-08-03

ASA: 2:44

Max ASA: 10:26

But what I'm getting is:

Date: 2015-08-03

ASA: 2:44

Max ASA: 2:44

The Max ASA value is calculating across all intervals for the entire day, but I need it to calculate for each interval then pull the max value from there.

My ASA calculation is as follows:

CREATE MEMBER CURRENTCUBE.[Measures].[Average Speed of Answer]
 AS 
    SUM([Measures].[Answer Time]) 
      / SUM([Measures].[Calls Answered]) 
        / 86400, 
FORMAT_STRING = "HH:mm:ss", 
VISIBLE = 1 ,  ASSOCIATED_MEASURE_GROUP = 'Call Stats Interval - Group'; 

As whytheq's question implies, there's an ambiguity about whether you're looking for the actual Max ASA on a per-call basis (which would require the CallID dimension whytheq suggests), or the Max (average) ASA on the interval (30 minute period) basis.

I think what you're looking for is the latter: find the interval (not the call, you don't have data at that granularity level) with the highest average ASA value (over all the calls in that interval).

You haven't posted your complete MDX code, but I think the problem is that your MAX value is being evaluated in the context of your query (probably at the [Date].[2015-08-03] level): it's giving the MAX of the already-calculated average at that level , when what you want is the MAX of the average at the interval level.

The solution is to calculate the average at the interval level, not at the level of your date slicer. I don't know your exact dimension and measure names, so they're generic in this sample:

WITH MEMBER Measures.ASA AS
Measures.[TimeToAnswer]/Measures.[NumberOfCalls]
MEMBER Measures.MaxASAPerHalfHour AS
MAX(DESCENDANTS([TimeDimension.CurrentMember,[TimeDimension].[HalfHourIntervals]),
Measures.ASA)
SELECT 
{Measures.[TimeToAnswer],Measures.  
[NumberOfCalls],Measures.ASA,Measures.MaxASAPerHalfHour} ON 0,
DESCENDANTS([TimeDimension].[Years].[2015],[TimeDimension].[Months]) ON 1
FROM [TheCube]

This query uses a session-level calculated member rather than a cube-level one, but the principle is the same. It shows all the months in 2015, with a max ASA per month. Because of the MAX function's first argument (the set of half hours), the first calculated measure is evaluated separately for each member of this set (ie for each half hour interval) before the MAX is evaluated.

I think you're looking for something along these lines:

CREATE MEMBER CURRENTCUBE.[Measures].[Max Speed of Answer]
 AS 
    MAX(
      [Dim_CallID].[Dim_CallID].MEMBERS,
      [Measures].[Answer Time]
    ) 
        / 86400, 
FORMAT_STRING = "HH:mm:ss", 
VISIBLE = 1 ,  ASSOCIATED_MEASURE_GROUP = 'Call Stats Interval - Group'; 

The above is assuming you have an attribute hierarchy like [Dim_CallID].[Dim_CallID].MEMBERS in your cube.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM