Pergunta

I have few tables in my data source in Power Pivot: One is a "Calendar" table from Azure Marketplace (http://datamarket.azure.com/dataset/boyanpenev/datestream) that I'm using for user friendly date representation. Clients table that has basic information about clients (ClientId, Client Name, Recent Address). Each clients may have multiple Accounts (AccountId, Account Name, ClientId). And I have AccountActivity table (AccountId, Date, Income). I've setup relations between tables accordingly.

I need to build a resulting table that is based off AccountActivity and will have Date(Month, Year), Sum of Incomes, # of accounts and # of clients. I was able to get everything except # of clients. Once I'm adding # of clients into the table it starts to complain that there is no reference and instead of showing proper # of clients it is showing total # of clients that does not have any relation to the accounts. Is there any way of making it work or I will have to add into AccountActivity ClientId column?

Foi útil?

Solução

You shouldn't need to add the ClientID to your source. You can just make a calculated column in your PowerPivot model. I recreated what I think you have

I made 3 tables with fake data that includes 4 clients, 6 accounts: enter image description here

I added them to my data model and then added the DateStream to my model and created relationships.

enter image description here

Then I:

  1. Went to the activity table in my model and added a calculated column [ClientID] with formula =related(Client[Client ID]).
  2. Created a calculated measure [# Clients]:=DISTINCTCOUNT(Activity[ClientID])
  3. Created a calculated measure [# accounts]:=DISTINCTCOUNT([AccountID])
  4. Created a calculated measure [Sum of Income]:=SUM([Income])

Then I created a pivot table. These calculated measures seem to work across all of your dimensions. enter image description here enter image description here

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top