Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Count unique values with filter on another column

Hi, 

I am having a table like

TimeCountryBuiding IDStatus
01_2021DEAopen
02_2021DEAopen
03_2021DEAopen
01_2021DEBclosed
02_2021DEBclosed
01_2021VNCopen 
02_2021VNCopen
01VNDclosed

 And I want to count the distinct building with status by country level

Country Open Closed

DE -------1------------1

VN-------1------------1

 

Is there any way to do it? please help, thank youuuu

  • Hi Anonymous  , 

     

    Actually, you can try use matrix table to do that without any measure.

    first step, add country to Rows and status to Columns. And you will get this : 

     

    second, add the building ID to Values but set it is count(distinct) via the "v" icon. Refer the following.

    Finally, the result:

     

     

    Or measures:

    open = calculate(DISTINCTCOUNT('Table'[Buiding ID]),'Table'[Status]="open")
    closed = CALCULATE(DISTINCTCOUNT('Table'[Buiding ID]),'Table'[Status]="closed")
     
    Pbix in the end you can refer.

    Best Regards

    Community Support Team _ chenwu zhu

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

2 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Anonymous Maybe:

    Count Open Measure = 
      COUNTROWS(DISTINCT(SELECTCOLUMNS(FILTER('Table',[Status] = "open"),"__Building",[Building])))
  • v-chenwuz-msft's avatar
    v-chenwuz-msft
    Community Support

    Hi Anonymous  , 

     

    Actually, you can try use matrix table to do that without any measure.

    first step, add country to Rows and status to Columns. And you will get this : 

     

    second, add the building ID to Values but set it is count(distinct) via the "v" icon. Refer the following.

    Finally, the result:

     

     

    Or measures:

    open = calculate(DISTINCTCOUNT('Table'[Buiding ID]),'Table'[Status]="open")
    closed = CALCULATE(DISTINCTCOUNT('Table'[Buiding ID]),'Table'[Status]="closed")
     
    Pbix in the end you can refer.

    Best Regards

    Community Support Team _ chenwu zhu

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.