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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
jnixon
Helper III
Helper III

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
Anonymous
Not applicable

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
Anonymous
Not applicable

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

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

Anonymous
Not applicable

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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors