Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

[Help] Count in DAX!

I have four tables. Table Agreement, Beaches, Connection and District.

Table Connection has a column AgreementID and BeachID.

Here is the relationship between the table:

Table Agreement &Table Connection through Agreement ID

Table Beaches & Table Connection through Beach ID

Table District & Table Beaches through District ID

 

Now, what I want to count is the number of Agreement ID per District. Sample data:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Result should be like this:

 

Should I create a measure column or merge queries?

Thank you!!!

  • Anonymous

     

    In this scenario, you already build the relationships between tables, then you just need to create measure like below: 

     

    Number Of ID =
    CALCULATE (
        COUNTA ( Agreement[AgreementID] ),
        ALLEXCEPT ( District, District[District] )
    )
    

    Regards,

2 Replies

  • v-sihou-msft's avatar
    v-sihou-msft
    Microsoft Employee

    Anonymous

     

    In this scenario, you already build the relationships between tables, then you just need to create measure like below: 

     

    Number Of ID =
    CALCULATE (
        COUNTA ( Agreement[AgreementID] ),
        ALLEXCEPT ( District, District[District] )
    )
    

    Regards,