Measure won't slice properly

japie06

New Member
Joined
Jun 7, 2016
Messages
4
Hi there!

I am a graduate intern at a big company and I'm having some trouble with creating a measure in PowerPivot.
I'm quite new with PowerPivot and I need some help. I am the first person to use PowerPivot in this office so I can't ask for help here.

I have a fact table that has basically all journal entries. See next table. All entries are done with a unique ID (serialnumber) for every product

IDDATEACCOUNT#AMOUNT
1102010-1-1900$1000

<tbody>
</tbody>

There is a dimension table with has all accounts allocated to a specific country and expense or revenue.
ACCOUNT#ExpenseCountry
900RevenueGermany

<tbody>
</tbody>

And another dimension table to split the dates.
The third dimension table contains product information, but also contains a column with a certain expense (Expense X).

IDExpense XProductNameProductcolour
110$50FlowerGreen

<tbody>
</tbody>

I made sure I made the correct relations between the tables of course. And slicing works in general.

To calculate the margin I need to deduct this expense x from the revenue. I already made a measure that shows total Revenue, that one was easy.

Now I need a measure to show the total for Expense X, related to productID. So I can slice in a pivot table on date and product name etc.

The problem is that I can't use RELATED function because the serial number is used multiple times in the fact table (journal entries can have the same serial number)
And if I use the SUM or CALCULATE function it won't slice properly.

So how can I calculate the total for expense X so it will slice properly?
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hi
Could you upload a little example into anywhere (maybe dropbox or other)?
Regards,
 
Upvote 0
Hi thanks for replying.

I uploaded a dummy database here

So I need to calculate the sum of Expense X in relation to the unique serialnumber. I need to be able to slice by month for example.
 
Upvote 0
Hi
If I understand you right a needed measure is
Code:
Total Expense:=CALCULATE(SUM('ProductTable'[Expense]), CALCULATETABLE('FactTable','ExpenseTable'[Expenses]="Revenue"))
Sorry, I can upload an example file for you but it is a problem - I have Excel 2016 Power Pivot but you have 2010. You cannot open a measure edit dialog.
Regards, Andrey.
 
Upvote 0
If you need with calculate total expense with count of SerialNumber in FactTable it is
Code:
CALCULATE(SUMX('ProductTable', 'ProductTable'[Expense]  * COUNTROWS(RELATEDTABLE('FactTable'))), 
CALCULATETABLE('FactTable','ExpenseTable'[Expenses]="Revenue"))
Good luck.
 
Upvote 0
If you need with calculate total expense with count of SerialNumber in FactTable it is
Code:
CALCULATE(SUMX('ProductTable', 'ProductTable'[Expense]  * COUNTROWS(RELATEDTABLE('FactTable'))), 
CALCULATETABLE('FactTable','ExpenseTable'[Expenses]="Revenue"))
Good luck.

Hey I have noticed that this forumula doesn't quite work. The reason is that in the fact table there can be several journal entries for revenue. This means that it will count the total expense twice for that specific serial number.

Is there a way to maybe only count unique values instead of count?
 
Upvote 0

Forum statistics

Threads
1,215,491
Messages
6,125,098
Members
449,205
Latest member
ralemanygarcia

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top