Muhammad Affan
Muhammad Affan

Reputation: 145

DAX Formula to Count all Distinct Customers in a specific region

I want to calculate all distinct customers in a specific region. But the problem here is that my table "Customer" does not have a direct relationship with territory table, instead it has an indirect relationship.

ER Diagram of my data model is :

enter image description here

Upvotes: 0

Views: 1324

Answers (1)

mkRabbani
mkRabbani

Reputation: 16908

You can use a measure with RELATED function as below. For direction in table relation, I have used table Sales and Region which will also give you correct answer-

customer_for_region_2 = 

CALCULATE(
    DISTINCTCOUNT(Sales[cus-id]),
    FILTER(
        Sales,
        RELATED(Region[regionid]) = 2 //Hard coded region id
    )
)

Upvotes: 1

Related Questions