Calculating getting monthly production into daily sales without flattening the tables.

alfranco17

Board Regular
Joined
Apr 14, 2013
Messages
198
I have a report where I need to calculate daily sales * production / monthly production. I get it by flattening three tables this model (here's the file, in case you would like to take a look):

original.png


... into this model, using Power Query:

flattened.png


It works a lot faster than the original SUMIFS and VLOOKUPS, and I was pretty happy with myself. Until I read Rob Collie's DAX FORMULAS FOR POWER PIVOT:

"Some Excel Pros who know their way around a database also write queries that flatten the data into one table before it's ever imported.

You do not need to do either of these anymore. In fact, you should not".

I have been trying to solve this without flattening for over four hours now. The closest I think I got was this formula to pull daily production into sales:

=CALCULATE(SUM(Production[Production]),Production[Date]=Expense[Date])

And then I tried this to get the whole month:

=CALCULATE(SUM(Production[Production]),Production[FY Month]=Expense[FY Month]).

But it did not work and besides it feels like flattening the table again.

I tried to use DATESBETWEEN, FILTER with ENDOFMONTH, DATE.

The result I'm trying to get is this one (it comes from the flattened version).

output.PNG


I would really appreciate any hints. I tried to do it with measures in the pivot table, but if I removed either the account, cost center or day it looked like it joining all against all, and the total would go from $25 to 9 times 25, one for each of the lines.

Thanks.
Armando.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
After a lot of trying, I found a way. I'll post it in case someone needs it too:

This formula will calculate the monthly budget:
=calculate(sum(budget[Budget]),datesbetween(calendar[date],startofmonth([calendardate]),endofmonth(calendar[date])))

It took forever to get it to work. You need to make sure to use only dates in the calendar table, and I still can't figure out what was wrong with the formula for three hours...
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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