[Help] Distinct Count with Filter from another Table

luuminhvuong93

New Member
Joined
Apr 9, 2017
Messages
1
[FONT=&quot]Hi all,[/FONT]
[FONT=&quot]I have a situation like in the photo, a simplified data in the excel attached.[/FONT]
[FONT=&quot]2 tables: Fact and Plan.[/FONT]
[FONT=&quot]*Fact: showing how much Volume was sold to a customer, by each Saleman. The period in example is Month 1 and 2 , but actually this is from 2015-2016 (24 months).[/FONT]
[FONT=&quot]Note that 1 customer can buy from multiple Salemen.[/FONT]
[FONT=&quot]*Plan: showing which Customer is being assigned to call by which Saleman (SM). This is the current assignment (2017).[/FONT]
[FONT=&quot]Note that 1 Customer can be assigned to multiple Salemen.[/FONT]
[FONT=&quot]Some customer in the fact table (i.e. E, G, H no longer exists)[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]Question: How to Calculate the: Number of Month (after a certain month, for example here is January) that a customer have volume >0?[/FONT]
[FONT=&quot](has to be a Calculated Column)[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]I tried the below formula - it works fine in the example simplified data, but it takes forever to calculate in my actual data (+1,000,000 rows) and froze my laptop. I am new , so I don't know what could be a better way to achieve this result. [/FONT]
[FONT=&quot] [/FONT]
=CALCULATE(DISTINCTCOUNT('Fact'[Month]),'Fact'[Cus<wbr style="box-sizing: inherit;">tomer]=EARLIER(Plan[Customer]),'Fact'[Volume]>0,'F<wbr style="box-sizing: inherit;">act'[Month]>1)[FONT=&quot] [/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]
large
[/FONT]

[FONT=&quot] [/FONT]
[FONT=&quot]Below is the example data - simplified:[/FONT]
[FONT=&quot]https://drive.google.com/file/d/0B7l_L5iVxXj-WE1Re<wbr style="box-sizing: inherit;">m9SQk9VLTQ/view?usp=sharing[/FONT]
[FONT=&quot] [/FONT]
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,225,730
Messages
6,186,698
Members
453,369
Latest member
positivemind

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