如何使用可选参数 pls 创建电源查询函数?我尝试了创建函数语法的各种排列,目前如下所示:
let
fnDateToFileNameString=(inFileName as text, inDate as date, optional inDateFormat as nullable text) =>
let
nullCheckedDateFormat = Text.Replace(inDateFormat, null, ""),
value = if nullCheckedDateFormat = ""
then inFileName
else Text.Replace(inFileName, inDateFormat, Date.ToText(inDate, inDateFormat ))
in
value
in
fnDateToFileNameString
我将它传递给一个看起来像这样的测试:
= fnDateToFileNameString("XXXXXXXXXXXXXXXXXX", #date(2015, 3, 21), null)
抛出:
"An error occurred in the fnDateToFileNameString" query. Expression.Error: we cannot convert the value null to type Text.
Details:
Value=
Type=Type