

Average only for NonEmpty - SSAS MDX
source link: https://www.codesd.com/item/average-only-for-nonempty-ssas-mdx.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Average only for NonEmpty - SSAS MDX
For one day (several datetime records possible) I want to create a 2nd measure computing an AVG
only for nonempty
values based on my 1st measure. I've tried the following :
"CREATE MEMBER CURRENTCUBE.[Measures].[M2]
AS AVG([Measures].[M1]),
VISIBLE = 1 , ASSOCIATED_MEASURE_GROUP = 'DATA' ;"
But the SSAS AVG function seems to return me a Sum:
DateTime "M1"
1/1/16 12:10 "10"
1/1/16 13:10 "12"
1/1/16 14:10
1/1/16 15:10 "9"
1/1/16 16:10
1/1/16 17:10 "21"
1/1/16 18:10
1/1/16 19:10 "2"
Average for nonempty Measure values (10+12+9+21+2)/5 nonempty Values = 10,8
If you want an average daily value then @whytheq showed a way to do it in MDX. But I believe you want a simple average. The proper way to do that in SSAS is to create a measure M1 tied to SQL column M1 with AggregateFunction=Sum (which you already have) and a second measure M1_Count on SQL column M1 in that measure group with an AggregateFunction=Count.
Then create a calculated measure:
CREATE MEMBER CURRENTCUBE.[Measures].[M1 Avg] as
IIF([Measures].[M1_Count]=0,null,[Measures].[M1]/[Measures].[M1_Count]);
Recommend
-
45
README.md ? NonEmpty
-
21
Markdown for documents, React for interaction, MDX for both! But how do Markdown and MDX arrive at HTML and JSX? The answer is Abstract Syntax Trees. Markdown is the perfect format for writing documents, documentat...
-
8
MDX – CrossJoins, Filters and “Perspective” October 20, 2018October 20, 2018 by TimG This post expands on a concept I touched on a few years back...
-
10
Released: SSRS and SSAS Management Packs (7.0.29.0)%3CLINGO-SUB%20id%3D%22lingo-sub-2028921%22%20slang%3D%22en-US%22%3EReleased%3A%20SSRS%20and%20SSAS%20Management%20Packs%20(7.0.29.0)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2028921%...
-
13
Component hydration with MDX in Next.js and NxIn the previous article, we explored how to render...
-
8
Having the live website (running locally on the computer) automatically refresh and reflect the changes made in Markdown is very convenient while writing a new blog article. The common behavior is to auto-refresh the page whenever something i...
-
5
1057:8 月 23 日收矿 235 美金 MDX 清算赔 2294 美金每天收一次矿,有点费油费,好在火币与 OK 的费用都很便宜,就是币安稍微贵一点。 浪费一点就浪费一点吧,每天知道赚多少钱赔多少钱,心里有底一点。8 月 23 日共收 235 美金,得益于最近一...
-
7
SSAS cube with date records advertisements I have to build a cube based on date range records, and not sure about the best way to proceed....
-
13
Microsoft Technologies, SQL Server,
-
6
Accessing SSAS via HTTP ...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK