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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
ljx0648
Helper II
Helper II

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 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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors