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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
lowcodelewis
New Member

Column with number of related records

Hi,

 

I have 2 tables. One with document locations (parent), one with documents (child). There is a 1:N relationship between these tables where a single document location can have many documents related to it. 

 

On my table of document locations, I want to be able to have a column which has a count of the number of related documents to that record. On my document locations table, there is a table column for documents as a result of the relationship between these Dataverse tables.

 

I am now trying to use a custom column with the following formula to produce the column. This works, but then because I think I'm almost doing a 'For All' type operation for every document location record, the number of API calls is dramatically high and things run incredibly slow and eventually fall over and the data just doesn't completely load at all.

 

This is the formula I tried in my custom column.

 

Table.RowCount([lcl_document])

 

Can anyone suggest the correct way to do this so that things dont slow down and just stop working?

 

Thank you in advance Power BI friends!

 

Lewis Baybutt

Microsoft Business Applications MVP

lowcodelewis.com

1 ACCEPTED SOLUTION
lowcodelewis
New Member

Thank you Sahir! I did wonder about doing things like this but then thought that it might be easier to go with a more direct approach. I've managed to achieve this and have blogged here:

 

Show a count of related records in Power BI - Low Code Lewis

 

The only difficulty is that the visual won't display records with 0 documents. So I may well have to go with the approach of producing a table of data with counts in Power Automate and make the counts strings to show this data.

 

Thank you for your help! 

View solution in original post

3 REPLIES 3
lowcodelewis
New Member

Thank you Sahir! I did wonder about doing things like this but then thought that it might be easier to go with a more direct approach. I've managed to achieve this and have blogged here:

 

Show a count of related records in Power BI - Low Code Lewis

 

The only difficulty is that the visual won't display records with 0 documents. So I may well have to go with the approach of producing a table of data with counts in Power Automate and make the counts strings to show this data.

 

Thank you for your help! 

Sahir_Maharaj
Super User
Super User

This way, you can simply retrieve the pre-calculated count from the table instead of recalculating it every time the table is loaded, reducing the number of API calls and improving the performance.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning
Sahir_Maharaj
Super User
Super User

Hello @lowcodelewis,

 

One way to reduce the number of API calls and improve the performance is to use Power Automate to pre-calculate the number of related documents for each document location and store it in the document locations table.

 

You can set up a flow that runs on a schedule (e.g. daily) to update the count of related documents for each record.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

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 Solution Authors