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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
kafreitass
Helper I
Helper I

Invoke 2 arguments in the function

Hi guys, I hope you are well.
I created a paginated API, and when invoking it everything works perfectly. But I need to do a customer consultation, and there is a parameter that is mandatory. So when invoking the function, I used two parameters, 1st from the pagination and 2nd from the client's code, but I'm not able to make this code dynamic. I need it as it is bringing all the pages, return me all the clients as well. How can I do this?

 

 function

Presentation1.png

 

Presentation1.png

let
totalpages = fx_Clientes_(1)[total_de_paginas,codigo_cliente_omie],
listOfPages = List.Generate(
() => [page = 1, data = fx_Clientes_(1)],
each [page] <= totalpages,
each [page = [page] + 1, data = fx_Clientes_([page]+1)]
)
in
listOfPages

3 REPLIES 3
PhilipTreacy
Super User
Super User

Hi @kafreitass 

You haven't been 100% clear on what it is you are trying to achieve.  Please supply examples of what that is.

When you say I need it as it is bringing all the pages, return me all the clients as well. How can I do this? 

What exactly do you mean?  Have you got lots of pages and clients to get data for?  Is that what the parameters are?  if so, what values can these parameters take?

 

If you are trying to create a query that loops and gets data for all combinations of pages and customers, you can try storing those values in a lists.  Then use List.Transform to call the function to get your data for each value in the list of customers e.g.

 

Customers = {"Alpha" , "Bravo" , "Charlie"},
Results = List.Transform(Customers , fx_Clientes_(Customers) )

 

Your code looks like it is calling the function twice, to do different things? 

 

The first time it's getting the total number of pages for a client?

 

The 2nd time, (in List.Generate) it's calling the function to get data for each of those pages up to the value of totalpages?

 

If you are tryign to do 2 different thinsg with a single function, you should create 2 functions.  1 each to do the 2 things you want.

 

Regards

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


PhilipTreacy
Super User
Super User

Hi @kafreitass 

 

Perhaps creating a parameter in PQ would be the answer to your problem

 

Deep Dive into Query Parameters and Power BI Templates | Microsoft Power BI Blog | Microsoft Power B...

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


@PhilipTreacythanks for answering

But from what I'm understanding this way I need to impute all the values in the parameter. And the values that will be created by the system?

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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