Understanding variable assignment

joel_h

New Member
Joined
Oct 25, 2017
Messages
7
Hi,
I'm new to this forum and a bit stuck, when I work with the Query Editor in Excel 2016. Editing in the advanced expression mode, which I understand is using the M query language, I get errors about Token Comma expected when I makde a custom function using the code below.

Its adding the row Result = "Hello World" that throws the error. Am I supposed to reference an existing variable (Result) in another syntax?

What I'm after here is understanding what I'm doing wrong. I haven't understood how to work with variables yet.

Code:
let IsEmptyValue = (PhoneNumberString as nullable text) as logical =>
let
    Result = if PhoneNumberString = null then "" else Text.Clean(Text.Trim(PhoneNumberString))
    Result = "Hello World"
in
    Result
in
    IsEmptyValue

Grateful for any helps from the experts here in the forum!
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
I'm not sure if I can edit my own post. Adding some stuff to my post
- I've found expression statements must be separated with a comma
- As a workaround I can declare new variables in each statement. It feels a bit clunky, though.

(Of course it also makes little sense to return a string here as the return method was set to logical... :))
 
Upvote 0

Forum statistics

Threads
1,215,375
Messages
6,124,580
Members
449,174
Latest member
chandan4057

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top