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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
ljx0648
Helper III
Helper III

Count distinct profile for each ID in M query

Hi guys,

 

I am a table of data similar to the one below:

 

IDAssign toWeb ProfileProfile Attribute 1Profile Attribute 2More Attribute columns
1AA1YN
1AA2NY 
2BBYN 
3CCYY 
4DD1YN 
4ED1NN 

 

You will see for each customer ID, it can be assigned to different representatives - One ID can have several representatives to service at the same time like ID 4.

 

Meanwhile, eahc ID can have multiple web profile created for different purposes. 

 

My goal of the exercise here is to add one column in my powberbi datatable by using M query to display the amount of unique/distinct web profile each ID has.

 

End result should looks like:

IDAssign toWeb Profile# Distinct Web Profile
1AA12
1AA22
2BB1
3CC1
4DD11
4ED11

 

Any tips are appreciated. 

 

Thank you!

1 ACCEPTED SOLUTION
RossEdwards
Solution Sage
Solution Sage

A simple approach could be to do the following:

  1. Duplicate your table, giving it a new name.  This will be your new source query. Right click on it and disable "Enable Load"
  2. Update your existing table to remove all its code and point to your newly duplicated source query
  3. Right click on your newly duplicated source query and select "Reference".  Also disable 'Enable Load' on this table.
  4. In this newly referenced query make use of the 'Group By' function like this:
    RossEdwards_0-1719443516672.png

     

  5. Inside your Table, do a merge query with your newly created ID Count query, joining ID to ID like this:
    RossEdwards_1-1719443606904.png

     

You should have an outcome that looks something like this:

RossEdwards_2-1719443663907.png

 

View solution in original post

1 REPLY 1
RossEdwards
Solution Sage
Solution Sage

A simple approach could be to do the following:

  1. Duplicate your table, giving it a new name.  This will be your new source query. Right click on it and disable "Enable Load"
  2. Update your existing table to remove all its code and point to your newly duplicated source query
  3. Right click on your newly duplicated source query and select "Reference".  Also disable 'Enable Load' on this table.
  4. In this newly referenced query make use of the 'Group By' function like this:
    RossEdwards_0-1719443516672.png

     

  5. Inside your Table, do a merge query with your newly created ID Count query, joining ID to ID like this:
    RossEdwards_1-1719443606904.png

     

You should have an outcome that looks something like this:

RossEdwards_2-1719443663907.png

 

Helpful resources

Announcements
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.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.