Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin 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.
OK, so say I make a simple function (in the advanced editor):
(test1 as text)=>
let
if test1 = "yes" then Source = "OK" else Source = "Dang"
in
SourceThis has an error of Token Identifier expeted for the if. What am I doing wrong??
The other thing I was wondering, is if test1 is not equal to "yes", instead of setting source as "Dang", am I able to exit the function with a text string as an error? In most programming languages you just return a value there and it will stop processing the rest of the function, but this doesn't seem an option in Power Query.
Solved! Go to Solution.
Hi @Anonymous -
the right synthax is:
(test1 as text)=>
let
Source = if test1 = "yes" then "OK" else "Dang"
in
Source
for the other question, it depends on what else have in your query, is the function the only code?
Did I answer your question correctly? Mark my answer as a solution!
Proud to be a Datanaut!
Hi @Anonymous -
the right synthax is:
(test1 as text)=>
let
Source = if test1 = "yes" then "OK" else "Dang"
in
Source
for the other question, it depends on what else have in your query, is the function the only code?
Did I answer your question correctly? Mark my answer as a solution!
Proud to be a Datanaut!
@LivioLanzo wrote:it depends on what else have in your query, is the function the only code?
This function would be called from another function. However, it is only this function I want to exit, and just return an error string. The parent function should continue to process and will just display the error.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 79 | |
| 38 | |
| 31 | |
| 27 | |
| 27 |