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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
alex1254
New Member

token tof expected - PowerBi Advanced Editor

I keep getting the error "token tof expected" when I add any code after the folowing block:

 

let
Source = Excel.Workbook(File.Contents("C:\Data Source.xlsx"), null, true),
#"Summary by Prov_Yr_Sheet" = Source{[Item="Summary by Prov_Yr",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(#"Summary by Prov_Yr_Sheet", [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"eg 1", type text}, {"eg 2", type text}, {"eg 3", Int64.Type}, {"Indications", type text}, {"eg 4", type text}, {"In any data? #(lf)(Y/N)", type text}, {"Year", type date}, {"Province", type text}, {"Source", type text}, {"Total, max-adj", type number}})
in
#"Changed Type"

 

I keep getting the error regardless of adding a comma after the above code. It's odd since this is the auto-generated code for importing the data. The code I've been trying to add is:

 

Beginning Value = calculate(sum('Summary by Prov_Yr'[Total, max-adj]),filter('Summary by Prov_Yr','Summary by Prov_Yr'[Year]=min('Summary by Prov_Yr'[Year]))),
Ending Value = calculate(sum('Summary by Prov_Yr'[Total, max-adj]),filter('Summary by Prov_Yr','Summary by Prov_Yr'[Year]=max('Summary by Prov_Yr'[Year]))),
# of Years = (max('Summary by Prov_Yr'[Year])-MIN('Summary by Prov_Yr'[Year])),

CAGR_T = iferror( ([Ending Value]/[Beginning Value])^(1/[# of Years])-1 , 0)

 

1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

@alex1254 ,

 

This error message means you should add a comma after each step except the last step, so please check this after you add new steps in advanced editor.

 

In addtion, the second part is dax code which can't be added in advanced editor. You should input power query(M code) in advanced editor, not dax code.

 

Community Support Team _ Jimmy Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yuta-msft
Community Support
Community Support

@alex1254 ,

 

This error message means you should add a comma after each step except the last step, so please check this after you add new steps in advanced editor.

 

In addtion, the second part is dax code which can't be added in advanced editor. You should input power query(M code) in advanced editor, not dax code.

 

Community Support Team _ Jimmy Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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