Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# avg mdx in sql 2012. Has it changed?

Posted on 2015-02-10
Medium Priority
159 Views
Hi

I had the following calculation in SQL 2008R2 cubes:

(([Measures].[Activity Count],[Age].[Hierarchy Adult - Child Age].[All].[Age 0-18])/AVG(Descendants([Date From Source Data].[Fiscal YQM].currentmember,[Date From Source Data].[Fiscal YQM].[Fiscal Month Name]),[Measures].[0-18])) * 1000

It doesn't seem to be working in SQL 2012, and whether the AVG is the problem or not I dont know yet. Is anybody aware that the AVG mdx function has changed in any way? It is red squiggle underlined in the mdx editor in the SSAS design time interface in SQL Server data tools. This makes me think that there is something that has changed but there are a few other elements that I need to check too.

Cheers

T
0
Question by:trawley
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• Learn & ask questions

LVL 49

Accepted Solution

PortletPaul earned 2000 total points
ID: 40602368
AVG(mdx)

Comparing 2008R2
https://msdn.microsoft.com/en-us/library/ms146067(v=sql.105).aspx
The Avg function calculates the average of the nonempty values of cells in the specified set by first calculating the sum of values across cells in the specified set, and then dividing the calculated sum by the count of nonempty cells in the specified set.
to SQL 20012
https://msdn.microsoft.com/en-us/library/ms146067(v=sql.110).aspx
The Avg function calculates the average of the nonempty values of cells in the specified set by first calculating the sum of values across cells in the specified set, and then dividing the calculated sum by the count of nonempty cells in the specified set.

I cannot see any difference (that matter).

{edited}
0

LVL 3

Author Comment

ID: 40641756
Yes the avg seems to get the squiggly red underline but it works just fine. Cheers T
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
###### Suggested Courses
Course of the Month10 days, 1 hour left to enroll

#### 610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.