Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello all,
I would like to change this calculated column definition to reference customer & product definitions found in dimProduct & dimCustomer tables:
Go from this:
// Distinct Count of Customer Key's per Product Key
CALCULATE(
DISTINCTCOUNT(factInvoices[CustomerKey]),
filter(factInvoices,factInvoices[ProductKey]=EARLIER(factInvoices[ProductKey]))
)
to this:
// Distinct Count of Customer Parents's per ProductParent
CALCULATE(
DISTINCTCOUNT(dimCustomer[CustomerParent]),
filter(factInvoices,dimProduct[ProductParent]=EARLIER(dimProduct[ProductParent]))
)
How can I force the calculated column expression to use row syntax for a related product & customer dimensions?
Thank you!!!!
Solved! Go to Solution.
Thank you @Anonymous !
I ended up finding a post here that helped me out: https://www.daxpatterns.com/related-distinct-count/
The earlier() functionality was giving me issues with the dimension table attributes, so I changed the distinct count to a measure named [# Customers]:
Then called that measure in a calculated column here:
Hi @bjackson202 ,
You can try to use RELATED() function.
Please try:
CALCULATE(
DISTINCTCOUNT(dimCustomer[CustomerParent]),
FILTER(
factInvoices,
RELATED(dimProduct[ProductParent]) = EARLIER(RELATED(dimProduct[ProductParent]))
)
)
CALCULATE(
DISTINCTCOUNT(dimCustomer[CustomerParent]),
FILTER(
factInvoices,
factInvoices[ProductKey] = EARLIER(dimProduct[ProductKey])
&& factInvoices[CustomerKey] = RELATED(dimCustomer[CustomerKey])
)
)
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you @Anonymous !
I ended up finding a post here that helped me out: https://www.daxpatterns.com/related-distinct-count/
The earlier() functionality was giving me issues with the dimension table attributes, so I changed the distinct count to a measure named [# Customers]:
Then called that measure in a calculated column here:
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
25 | |
10 | |
7 | |
6 | |
6 |
User | Count |
---|---|
30 | |
11 | |
11 | |
10 | |
6 |