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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
JohnFabric
Helper I
Helper I

Running a function only once per unique value

Hello, for a report I am building I need to get the reporting structure of each user in the report. I have a list of user emails like this

 

JohnFabric_0-1729896984057.png

And I have a custom function I run that calls an API that gets the users management structure. This works great but currently this custom function runs on every single row, even if I have already run it for a user

 

= Table.AddColumn(#"Changed Type3", "SVP", each try fnGetSVP([AssignedTo.UserEmail]) otherwise "")

 

This is a large table which means I'm making tens of thousands of API calls, even though there are only ~700 unique users in the table, so the vast majority of those API calls are duplicates which drastically increases the the time it takes the report to run. I cannot use the built in "Remove Duplicates" function because I need to preserve every row for the final report, and it doesnt look like there is a good way to remove duplicates and preserve each row. 

 

So what I'm looking for is a way to run the function only on unique values. I've tried a few different things, such as extracting the column, removing duplicates, running the function, then creating a one to many relationship back with my original query but that didn't work. If there is a way to do this I'd appreciate the intel!

1 ACCEPTED SOLUTION
Omid_Motamedise
Super User
Super User

Creat another query including the unique emails, then call the app for the unique list of emails and then merge it's result with your table.


If my answer helped solve your issue, please consider marking it as the accepted solution.

View solution in original post

2 REPLIES 2
Omid_Motamedise
Super User
Super User

Creat another query including the unique emails, then call the app for the unique list of emails and then merge it's result with your table.


If my answer helped solve your issue, please consider marking it as the accepted solution.
lbendlin
Super User
Super User

And I have a custom function I run that calls an API that gets the users management structure

There's no need for that.  Let the PATH DAX function do the work for you.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors