0
votes

I'm working on creating a model in Power BI that pulls data from a third party API. The API call has two parameters; UserID and AccountType.

I have an existing query in my PowerBI that provides a de-duplicated list of all combinations of UserID and AccountType we store in the system.

Using the guidelines from this article, I managed to create a function with two parameters that I can invoke manually to properly return the dataset I expect to get from the API. The manual function call resembles something like this:

fnMyFunction("12345", "ABCDEF")

However, we'd need to run that function for every row in the de-duplicated query from above. I've so far not managed to figure out the proper syntax of doing this. I'm quite sure we're very close on getting it to work, but I'm coming up blank as to how to properly invoke my function.

What I've tried:

fnMyFunction(myQuery[UserId], myQuery[AccountType])

This yields the following error: 1.Error: We cannot convert a value of type List to type Text.`

fnMyFunction(each myQuery[UserId], each myQuery[AccountType])

This yields the same error as above.

I've found numerous references stating I can use a query as input for a parameter, but all of those are based on a single column, where we'd need it to work on a combination of two columns.

How would I be able to accomplish my goal of calling our function using data returned by an existing query as input for the function?

Thank you.

1

1 Answers

2
votes

I'd recommend invoking your function as a custom column in your myQuery table.

Add a custom column to myQuery with

fnMyFunction([UserId], [AccountType])

as the formula defining it.