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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
bcoro
Frequent Visitor

How to add a calculated column in power query based on a related table

I created this measure to count the total enrollment ID per client ID. I would like to do this through Power Query, but I don't fully comprehend the process/language in Power Query. 
 
Total Enrollments = COUNTX(RELATEDTABLE(Data),'Data'[EE UID])
 
The 'Client' Table has a unique ID,
The 'Data' Table has duplicate client IDs with unique enrollment IDs. 
1 ACCEPTED SOLUTION
ajaybabuinturi
Solution Sage
Solution Sage

Hi @bcoro,
I would suggest, you can follow the below steps

  1. Perform "Group By" on Client ID column in the "Data Table"
    Power Query Editor > Transform > Group By >Rename the column as your wish. Results looks like below
    Data Table:
    ajaybabuinturi_0-1747964188411.png
    Group By Result:
    ajaybabuinturi_1-1747964217414.png
  2. Merge the result into the "Client Table":
    Power Query Editor > Home > Merge Queries > Rename the column as your wish.
    Client Table:
    ajaybabuinturi_2-1747964461509.png

    Merge Results:

    ajaybabuinturi_3-1747964498444.png

If you don't want do the process, you can take the reference data table and do the same procedure.
Please let me know if you any questions.

 

 

Thanks,
If you found this solution helpful, please consider giving it a Like👍 and marking it as Accepted Solution✔. This helps improve visibility for others who may be encountering/facing same questions/issues.

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi @bcoro 

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

Anonymous
Not applicable

Hi @bcoro 
Thank you for reaching out microsoft fabric community forum.
I wanted to check if you had the opportunity to review the information provided by @ajaybabuinturi . Please feel free to contact us if you have any further questions. If his response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.

Ashish_Excel
Super User
Super User

Hi,

Share some data to work with and show the expected result.  Share data in a format that can be pasted in an MS Excel file.

ajaybabuinturi
Solution Sage
Solution Sage

Hi @bcoro,
I would suggest, you can follow the below steps

  1. Perform "Group By" on Client ID column in the "Data Table"
    Power Query Editor > Transform > Group By >Rename the column as your wish. Results looks like below
    Data Table:
    ajaybabuinturi_0-1747964188411.png
    Group By Result:
    ajaybabuinturi_1-1747964217414.png
  2. Merge the result into the "Client Table":
    Power Query Editor > Home > Merge Queries > Rename the column as your wish.
    Client Table:
    ajaybabuinturi_2-1747964461509.png

    Merge Results:

    ajaybabuinturi_3-1747964498444.png

If you don't want do the process, you can take the reference data table and do the same procedure.
Please let me know if you any questions.

 

 

Thanks,
If you found this solution helpful, please consider giving it a Like👍 and marking it as Accepted Solution✔. This helps improve visibility for others who may be encountering/facing same questions/issues.

Yes, it worked.

I'm assuming I should duplicate my data table because I don't want it to remain grouped. Is there a way around that? At some point, I would like to add to this table with other information from the data table but don't want to create multiple tables.  

Hi @bcoro,

Here is the alternate workaround

 

  1. Merge the Client Table with the Data Table based on the Client ID field. Make sure the Client Table as the first table and the Data Table as the second table.
  2. Expand the merged table to get the EE UID field.
    ajaybabuinturi_0-1748055437078.png
  3. Select Client ID and Client Name then click on Group By and rename the New column name as Total Enrollments and hit the OK.
    ajaybabuinturi_1-1748055466373.png
  4. Using the above steps you will get required resuts and you can able to add new fileds to the Client Table in future.
    ajaybabuinturi_2-1748055484766.png

Thanks,
If you found this solution helpful, please consider giving it a Like👍 and marking it as Accepted Solution✔. This helps improve visibility for others who may be encountering/facing same questions/issues.

ryan_mayu
Super User
Super User

@bcoro 

in pq you can try to use merge query function to get a column from a related table.

 

https://learn.microsoft.com/en-us/power-query/merge-queries-overview?wt.mc_id=DP-MVP-5004616

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors