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

Distinct count needed on attribute in snowflake dimension for calculated measure

$
0
0
HiI have created a cube called Product Sales. My fact table fProductSales has the following columns: SalesKey, ProductKey, SalesStatusKey, Revenue and NoOfProducts. I have a Product Sales measure group from this with Revenue and NoOfProducts as measures.I then have a dSales dimension table that joins to the fact table on SalesKey. This table has SalesKey, SaleCampaignKey, DateSignedKey and EmployeeKey. I have a Sales cube dimension from this.I then have a dEmployee dimension table that joins to dSales dimension on EmployeeKey. This table has EmployeeKey, EmployeeAltKey (business key) FirstName, Surname, Title, Department etc. I have a Employees cube dimension from this.One of the measures i need to create is Revenue/distinct(Agents). My dEmployee table contains all employees in the company but the dProductFact table will only link to employees that are agents. So i created a Distinct Count measure on the dEmployee table on the EmployeeAltKey column resulting in a new measure group Agents and measure NoOfAgents.I have then defined the Dimension Usage for this new measure group as a fact relationship type with the Employee dimension, and a many-to-many relationship type with the Sales dimension (this did not make sense to me but is the only thing that returns values when slicing by Sales dimension). I do have a number of other dimensions in the cube but at this stage Im just trying to get the basics working to understand the theory.The questions and issues I have are: 1. Have I done this the best way possible? 2. If i browse the cube in Excel to check the counts, the counts are correct if I am slicing by Sales attributes but if i just display totals for the measures for the whole cube then the count is for all employees and not just agents. ie It is not limited by what is in the fact table as if it does not take into account the relationship between dEmployee and fProdcutSales. 3. When i get the distinct count working properly, how do I then define the calculated measure Revenue/distinct(Agents) ? Do i need to scope this calculation in a particular way? 4. I would have thought the Dimension Usage relationship between the Sales dimension and the Agents measure group should have been a regular one? This resulted in missing key errors and if i ignore the errors and deploy then the measure does not return any values?Many thanks for any help.CheersGarry

Viewing all articles
Browse latest Browse all 1341

Trending Articles