cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
jnixon Regular Visitor
Regular Visitor

how to pass multiple optional parameters to a custom function?

I've experimented, but I have not come up with a solution for this scenario:

My Custom function accepts three parameters, the last two of which are optional. I want to pass parameters one and three only. How do I call the function?

1 ACCEPTED SOLUTION

Accepted Solutions
mcybulski Member
Member

Re: how to pass multiple optional parameters to a custom function?

Make sure that your second argument has no type. You will then be allowed to pass a null value as the second option. 

View solution in original post

3 REPLIES 3
mcybulski Member
Member

Re: how to pass multiple optional parameters to a custom function?

Make sure that your second argument has no type. You will then be allowed to pass a null value as the second option. 

View solution in original post

jnixon Regular Visitor
Regular Visitor

Re: how to pass multiple optional parameters to a custom function?

Thanks Mike - back to the rescue!

That works indeed.  Testing further, i found that this will also work with passing null, and with the added benefit of validating the data type of the parameters:

 

(P1 as text, optional P2 as nullable text, optional P3 as nullable text) =>

let

   T1 = "P1 = " & P1,

   T2 = if (P2 = null) then "; P2 = null()" else "; P2 = " & P2,

   T3 = if (P3 = null) then "; P3 = null()" else "; P3 = " & P3,

   Return = T1 & T2 & T3

in

   Return

mcybulski Member
Member

Re: how to pass multiple optional parameters to a custom function?

Hey J, I forgot that you could use nullable text. I wish more of the standard PQ functions would use them.

Helpful resources

Announcements
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors (Last 30 Days)