![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
hi, i'm new to Analysis Services and MDX, so thanks in advance for your patience :-). i'd like to create a set of (calculated member) measures based on a string field (column name: LABEL) of my fact table. let's say for each record, the string contains the values A, B, C, D, or E. i'd like to create eight measures -- CountA, PercentA, CountB, PercentB, CountC, PercentC, CountOther, and PercentOther. these should be: CountA = count of LABEL with a value of A PercentA = CountA/# non-NULL LABEL instances ... CountOther = count of anything that is not A, B, or C PercentOther = CountOther/# non-NULL LABEL instances how could i do this? can i create a numeric calculated member based on a string comparison that can be aggregated? also, if any of you have pointers/suggestions for good sources for ramping up on creating these kinds of measures, i'd really appreciate it! thanks much! wg |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
I can think of a couple of approaches to this problem. Whereas I would favor creating a dimension from the LABEL column, and using that to define the calculated members, it would entail more up-front work. So the other approach is: Add a measure: CountAll, of Aggregation Function: "Count". Add a series of measures to the cube, each using the default "Sum" Aggregation Function. Define the Source Columns for these measures with SQL expressions like: - CountA => case MyFact.LABEL when 'A' then 1 else 0 end - CountB => case MyFact.LABEL when 'B' then 1 else 0 end - CountC => case MyFact.LABEL when 'C' then 1 else 0 end - CountOther => case MyFact.LABEL when 'A' then 0 when 'B' then 0 when 'C' then 0 else 1 end Add the Percent calculated members, defined like: - PercentA => CountA/CountAll .etc The assumption above was that LABEL is non-null. To allow for nulls, the SQL expressions should include coalesce(). - Deepak *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#5
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |