Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi,
I am trying to paramaterize the number of days within date.isinpreviousNdays(datetime,number of days) function. But I am getting following error.
Expression.Error: We cannot convert the value "& DaysPrior &" to type Number.
Details:
Value=& DaysPrior &
Type=Type
Please find below my entire code:
let
Source = Exchange.Contents(ExchangeEmailID),
Mail1 = Source{[Name="Mail"]}[Data],
#"Filtered Rows1" = Table.SelectRows(Mail1, each Text.StartsWith([Folder Path], "\Inbox\")),
#"Filtered Rows" = Table.SelectRows(#"Filtered Rows1", each Date.IsInPreviousNDays([DateTimeReceived], "& DaysPrior &") or Date.IsInCurrentDay([DateTimeReceived])),
#"Filtered Rows2" = Table.SelectRows(#"Filtered Rows", each Text.StartsWith([Subject], "Cash")),
#"Filtered Rows3" = Table.SelectRows(#"Filtered Rows2", each ([HasAttachments] = true)),
#"Filtered Rows4" = Table.SelectRows(#"Filtered Rows3", each Text.Contains([DisplayTo], "Dennis, Kristy A.") or Text.Contains([DisplayTo], " Matteson, Heather E") or Text.Contains([DisplayTo], "Galentine, Ginnie")),
#"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows4",{"Subject", "Attachments"}),
#"Inserted Text After Delimiter" = Table.AddColumn(#"Removed Other Columns", "Text After Delimiter", each Text.AfterDelimiter([Subject], " "), type text),
#"Renamed Columns" = Table.RenameColumns(#"Inserted Text After Delimiter",{{"Text After Delimiter", "Date"}}),
#"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"Date", type date}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Subject"}),
#"Added Custom" = Table.AddColumn(#"Removed Columns", "Custom", each [Attachments]{0}[AttachmentContent]),
#"Filtered Hidden Files1" = Table.SelectRows(#"Added Custom", each [Attributes]?[Hidden]? <> true),
#"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File from CashBalance (2)", each #"Transform File from CashBalance (2)"([Custom])),
#"Removed Other Columns1" = Table.SelectColumns(#"Invoke Custom Function1",{"Date", "Transform File from CashBalance (2)"}),
#"Expanded Table Column1" = Table.ExpandTableColumn(#"Removed Other Columns1", "Transform File from CashBalance (2)", Table.ColumnNames(#"Transform File from CashBalance (2)"(#"Sample File (2)"))),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded Table Column1",{{"Portfolio", type text}, {"Cash Balance", Currency.Type}})
in
#"Changed Type1"
Please let me know ASAP how to paramaterize the 90 days within the function.
Solved! Go to Solution.
@Anonymous,
I am assuming DaysPrior is your parameter, you can remove the double quotes and the & signs, it should work. If that still doesnt work, check your parameter type or to convert DaysPrior to number using Numbers.From(DaysPrior)
@Anonymous,
I am assuming DaysPrior is your parameter, you can remove the double quotes and the & signs, it should work. If that still doesnt work, check your parameter type or to convert DaysPrior to number using Numbers.From(DaysPrior)
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!