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

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
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,223,909
Messages
6,175,315
Members
452,634
Latest member
cpostell

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