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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.