Quantcast
Channel: SQLServerCentral » Data Warehousing » Analysis Services » Latest topics
Viewing all articles
Browse latest Browse all 1341

MDX for weighted average?

$
0
0
Hi,I'm looking for some help writing some MDX for a weighted average. I'm relatively new to MDX so all help is appreciated. Some example data (Quality Level is Pass / Inspect ):[code="plain"]Account Volume Inspect Pass Fail Quality LevelAccount 1 100 4 3 1 75.00%Account 2 7 1 1 0 100.00%Account 3 231 9 9 0 100.00%Account 4 303 12 11 1 91.67%Account 5 11 0 0 0 NA[/code]Our weighted average is defined as ( Volume * Quality Level ) / Volumel. We need to exclude any rows where there are no inspections. So for the above data the Weighted Quality Level would be defined as:(A1V * A1QL) + (A2V * A2QL) + (A3V * A3QL) + (A3V * A3QL) / A1V + A2V + A3V + A42V(100 * .75) + (7 * 1) + (231 * 1) + (303 * .9167) / 100 + 7 + 231 + 303= 92.16% My biggest issue is filtering out Account 5 so the number calculates correctly.Thanks.-Tom

Viewing all articles
Browse latest Browse all 1341

Trending Articles