Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Kavindya
Frequent Visitor

Power BI Measure for Distinct Count

Hi, 

I have two tables calling Agent Join Table and Summary Table. So I required to identify how many agents activated from the particular department and date wise. 

 

Required to get the Distinct count date and department wise to the below column. 

No fo Active Agents

 

Have to Add a filter as

Agent_Join.Department_ID = Summary.Department_ID

and 

Agent_Join.Date = Summary.Date

 

Agent Join

  
Department IDDateAgent ID
112/12/20221000001
113/12/20221000002
114/12/20221000003
115/12/20221000004
212/12/20221000001
212/12/20221000002
213/12/20221000003
312/12/20221000001
313/12/20221000009
313/12/20221000010
412/12/20221000001
413/12/20221000002
415/12/20221000013

 

 

Summary

    
DateDepartmetnIDDepartment NameNo fo Agents Assigned to DepartmentNo fo Active Agents
12/12/20221ABC3 
12/12/20222CDA6 
12/12/20223AHN7 
12/12/20224NDH5 
13/12/20221ABC3 
13/12/20222CDA6 
13/12/20223AHN7 
13/12/20224NDH5 
14/12/20221ABC3 
14/12/20222CDA6 
14/12/20223AHN7 
14/12/20224NDH5 
15/12/20221ABC3 
15/12/20222CDA6 
15/12/20223AHN7 
15/12/20224NDH5 
     
1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @Kavindya 

According to your description, do you mean you want to add a column in "Summary" table to calculate the distincount of the [Agent ID] in 'Agent Join' table where Agent_Join.Department_ID = Summary.Department_ID and  Agent_Join.Date = Summary.Date?

If this , here are the steps you can refer to :
(1)My test data is the same as yours.

(2)We can click "New column" and enter:

No fo Active Agents = var _date = [Date]
var _departmentID=[DepartmetnID]
var _t =DISTINCT(SELECTCOLUMNS( FILTER('Agent Join','Agent Join'[Department ID]=_departmentID && 'Agent Join'[Date]=_date) , "Agent ID",[Agent ID]))
return
COUNTROWS(_t)+0

Then we can get your need:

vyueyunzhmsft_0-1671679004084.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

View solution in original post

2 REPLIES 2
v-yueyunzh-msft
Community Support
Community Support

Hi , @Kavindya 

According to your description, do you mean you want to add a column in "Summary" table to calculate the distincount of the [Agent ID] in 'Agent Join' table where Agent_Join.Department_ID = Summary.Department_ID and  Agent_Join.Date = Summary.Date?

If this , here are the steps you can refer to :
(1)My test data is the same as yours.

(2)We can click "New column" and enter:

No fo Active Agents = var _date = [Date]
var _departmentID=[DepartmetnID]
var _t =DISTINCT(SELECTCOLUMNS( FILTER('Agent Join','Agent Join'[Department ID]=_departmentID && 'Agent Join'[Date]=_date) , "Agent ID",[Agent ID]))
return
COUNTROWS(_t)+0

Then we can get your need:

vyueyunzhmsft_0-1671679004084.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

djurecic
Super User
Super User

Hi @Kavindya ,

 I'm not sure I fully understand the question, but DISTINCTCOUNT is the dax function you can use.

 

https://learn.microsoft.com/en-us/dax/distinctcount-function-dax

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.

Top Solution Authors