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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rodneyc8063
Helper V
Helper V

Create dynamic reports for multiple values? (Microsoft Training Clarification)

So Im going through the Microsoft Training for DA100 and am a bit confused by something in one of the modules.

 

Specifically on this page in the section "Create dynamic reports for multiple values"

 

https://docs.microsoft.com/en-us/learn/modules/manage-datasets-power-bi/2-report-parameters

 

Now this entire page is talking about parameters and how to use parameters. 

 

So going through the given example it says to "Right click query 1 and select [Create function]" - A new window will pop up asking for a name for the function as shown below

 

2-create-function-window-ss.png

 

So far this is easy, I just gave a name to a function. The [Parameters: SalesPerson] if I understand correctly was the parameter that was created earlier on in the example and is being used in the query. Cool beans so far

 

After clicking OK it should then pop up the following screen

 

2-function-query-pane-ssm.png

So here I get a bit confused. I dont understand why suddenly it would show [GetSalesPerson (1)] with another subfolder [GetSalesPerson(3)]? 

 

Moving along - The example goes on to say to go to the "Sheet1" query (which is now renamed as SalesPersonID supposedly) and "Invoke Custom Function" which then yields the following screen

 

2-invoke-custom-function-window-ss.png

 

So this is where I get quite lost......

 

So there is a drop down "Function Query" - I choose the function that was created earlier "GetSalesPerson", which will then auto-populate the "New column name"

 

I see the previously defined parameter "SalesPerson" - Ok - And another drop down listing "SalesPersonID"

 

Im not sure what happened here - As when I think function, I think PL/SQL functions/procedures where there is code written. Based on this example, no code was written - So Im not sure exactly whats going on?

 

Also, Im not sure how realistic this example would be - To have someone input a list of excel values in order to pull data in. Does anyone have any better examples of when to use "Invoke a custom function"?

 

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @rodneyc8063 ,

 

The custom function uses the columns of the table were you invoke it to populate the parameters of the function.

 

In this case what you see is that they create a new Sheet 1 where the columns are the SalespersonID

sales_person.png

Then they use the values on this table to call the custom function.

 

So in summary the SalesPersonId you see on the image of the custom function is the column name on the table where you are calling the function.

 

In fact having an SQL Query on the power query if you replace the filtering on the SQL syntax by a parameter you can in fact use an input from the user (excel or other type) to make the SQL return a different filter from the ones you created the query, this is the same behaviour has you have in any SQL consultation that you can define variable to filter your information the only thing is that Power BI allows you to add the values of those parameters in several different ways using the custom function.

 

Regarding the image of the folders is just one way or organizing the information if you right click a query you can place it within a folder.

 

 
 
 
 
 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

4 REPLIES 4
MFelix
Super User
Super User

Hi @rodneyc8063 ,

 

The custom function uses the columns of the table were you invoke it to populate the parameters of the function.

 

In this case what you see is that they create a new Sheet 1 where the columns are the SalespersonID

sales_person.png

Then they use the values on this table to call the custom function.

 

So in summary the SalesPersonId you see on the image of the custom function is the column name on the table where you are calling the function.

 

In fact having an SQL Query on the power query if you replace the filtering on the SQL syntax by a parameter you can in fact use an input from the user (excel or other type) to make the SQL return a different filter from the ones you created the query, this is the same behaviour has you have in any SQL consultation that you can define variable to filter your information the only thing is that Power BI allows you to add the values of those parameters in several different ways using the custom function.

 

Regarding the image of the folders is just one way or organizing the information if you right click a query you can place it within a folder.

 

 
 
 
 
 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix 

 

Hm - I just wanted to clarify then, Im assuming then that a custom function is not simply limited to one parameter or one column input? Multiple parameters can be used with multiple column inputs?

 

Thank you for clarifying so far though, that does make more sense 🙂

Correct.

 

If you look at the syntax of a custom function you will have something similar to:

let
    Source = (Parameter1 as text) => let
        Source = ...,
        Step1 = ... Parameter1,
        Step2 = ...
    in
        Step2
in
    Source

In the values in parentesis you can setup something similar to this:

let
    Source = (Parameter1 as text, Parameter2 as number) => let
        Source = ...,
        Step1 = ... Parameter1,
        Step2 = ... Parameter2
    in
        Step2
in
    Source

This way you will have has many parameter has you need and you can place them on the steps where you need them.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Many thanks @MFelix !

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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