Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
maneeshsinha
Regular Visitor

PowerBI Advance Editor Error - Token Eof expected

Hi,

I am getting an error message "Token Eof expected." while adding additional 'let' in an existing M function. Second screenshot is attached for reference.

 

The first 'let' section is working perfectly fine (first screenshot is attached for reference). Getting an error only when adding an additional second 'let' statement.

 

Please help. Thanks!!

 

let
Source = Excel.Workbook(File.Contents("C:\Users\SINHAM\OneDrive\MANEESH\DCS\1. BI Dashboard\PowerBI Dashboard\1. Latest-Version\1. FINAL\1. Dash\CMDB Baseline IP Subnet Ranges Expanded.xlsx"), null, true),
#"CMDB IP Address_Sheet" = Source{[Item="CMDB IP Address",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(#"CMDB IP Address_Sheet", [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Environment", type text}, {"Subnet", type text}, {"Suffix", Int64.Type}})
in
#"Changed Type"

 

let
Source = Excel.Workbook(File.Contents("C:\Users\SINHAM\OneDrive\MANEESH\DCS\1. BI Dashboard\PowerBI Dashboard\1. Latest-Version\1. FINAL\1. Dash\CMDB Baseline IP Subnet Ranges Expanded.xlsx"), null, true),
IsIPInSubnet = (IPAddress as text, Subnet as text) =>
let
SubnetAddress = Text.BeforeDelimiter(Subnet, "/"),
SubnetMask = Text.AfterDelimiter(Subnet, "/"),
SubnetBits = Text.ToNumber(SubnetMask),
IPBinary = Binary.From(Number.FromText(Text.Combine(List.Transform(Text.Split(IPAddress, "."), each Text.PadStart(_, 3, "0")), ""))),
SubnetBinary = Binary.From(Number.FromText(Text.Combine(List.Transform(Text.Split(SubnetAddress, "."), each Text.PadStart(_, 3, "0")), ""))),
SubnetMaskBinary = Number.ToText(Binary.ToNumber(List.FirstN( Binary.ToList(Number.ToBinary(2^32 - 2^ (32 - SubnetBits))), 4))),
Result = SubnetBinary = Binary.And(IPBinary, SubnetMaskBinary)
in
Result
in
IsIPInSubnet

 

 

PowerBI NO_Error.png

 

 

PowerBI Error - Token Eof expected.png

 

3 ACCEPTED SOLUTIONS
parry2k
Super User
Super User

@maneeshsinha you have to add 2nd let in a seperate query:

 

let
Source = Excel.Workbook(File.Contents("C:\Users\SINHAM\OneDrive\MANEESH\DCS\1. BI Dashboard\PowerBI Dashboard\1. Latest-Version\1. FINAL\1. Dash\CMDB Baseline IP Subnet Ranges Expanded.xlsx"), null, true),
IsIPInSubnet = (IPAddress as text, Subnet as text) =>
let
SubnetAddress = Text.BeforeDelimiter(Subnet, "/"),
SubnetMask = Text.AfterDelimiter(Subnet, "/"),
SubnetBits = Text.ToNumber(SubnetMask),
IPBinary = Binary.From(Number.FromText(Text.Combine(List.Transform(Text.Split(IPAddress, "."), each Text.PadStart(_, 3, "0")), ""))),
SubnetBinary = Binary.From(Number.FromText(Text.Combine(List.Transform(Text.Split(SubnetAddress, "."), each Text.PadStart(_, 3, "0")), ""))),
SubnetMaskBinary = Number.ToText(Binary.ToNumber(List.FirstN( Binary.ToList(Number.ToBinary(2^32 - 2^ (32 - SubnetBits))), 4))),
Result = SubnetBinary = Binary.And(IPBinary, SubnetMaskBinary)
in
Result
in
IsIPInSubnet


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

parry2k
Super User
Super User

@maneeshsinha in left pane, right click -> new query -> Blank query and then click advanced editor and this is where you will copy the 2nd let.

 

parry2k_0-1696472954445.png

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

What does it show when you click on "Show error"

 

Seems it's unhappy with the highlighted part as it has been underlined:

AndreDeLange_0-1696476256992.png

 

View solution in original post

7 REPLIES 7
parry2k
Super User
Super User

@maneeshsinha in left pane, right click -> new query -> Blank query and then click advanced editor and this is where you will copy the 2nd let.

 

parry2k_0-1696472954445.png

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k Tried as suggested and got the new error 'Token ',' expected, screenshot below for reference. I reckon, I do have ',' in place. Am I missing somewhere?

 

maneeshsinha_0-1696473599084.png

 

 

What does it show when you click on "Show error"

 

Seems it's unhappy with the highlighted part as it has been underlined:

AndreDeLange_0-1696476256992.png

 

Hi @AndreDeLange , thanks for the suggestion. Yes, you're right, I replaced '2^32' with 'Number.Power(2, 32)' and it's working perfectly fine now 🙂

 

Thank you so very much @AndreDeLange  & @parry2k for all your help. Much appreciated!!

 

Regards,

Maneesh.

Excellent, glad it helped

parry2k
Super User
Super User

@maneeshsinha you have to add 2nd let in a seperate query:

 

let
Source = Excel.Workbook(File.Contents("C:\Users\SINHAM\OneDrive\MANEESH\DCS\1. BI Dashboard\PowerBI Dashboard\1. Latest-Version\1. FINAL\1. Dash\CMDB Baseline IP Subnet Ranges Expanded.xlsx"), null, true),
IsIPInSubnet = (IPAddress as text, Subnet as text) =>
let
SubnetAddress = Text.BeforeDelimiter(Subnet, "/"),
SubnetMask = Text.AfterDelimiter(Subnet, "/"),
SubnetBits = Text.ToNumber(SubnetMask),
IPBinary = Binary.From(Number.FromText(Text.Combine(List.Transform(Text.Split(IPAddress, "."), each Text.PadStart(_, 3, "0")), ""))),
SubnetBinary = Binary.From(Number.FromText(Text.Combine(List.Transform(Text.Split(SubnetAddress, "."), each Text.PadStart(_, 3, "0")), ""))),
SubnetMaskBinary = Number.ToText(Binary.ToNumber(List.FirstN( Binary.ToList(Number.ToBinary(2^32 - 2^ (32 - SubnetBits))), 4))),
Result = SubnetBinary = Binary.And(IPBinary, SubnetMaskBinary)
in
Result
in
IsIPInSubnet


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi @parry2k ,

 

I truly appreciate your quick response. Thanks so much.

 

I'm pretty new to PowerBI, hence excuse me for asking a silly questions, please 🙂

 

How to create a seperate query to add a 2nd 'let'? 

 

Usually, I navigate to Advanced Editor by clicking on "Home" => "Transform Data" => "View" => "Advanced Editor". I can't see an option to create a seperate query.

 

Thank you so much again in advance for all your assistance!!

 

Regards,

Maneesh.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.