cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
BenTen22
Regular Visitor

Token Equal Expected

Hey all,

 

I'm getting Token Equal expected for the second to last column i'm adding (highlighted). Can't for life of me workout why though. Any tips would be much appreciated.

 

= let
Dates = BaseDateTable,
CurrentDate = DateTime.Date(DateTime.LocalNow()),
CurrentYear = Date.Year(DateTime.Date(DateTime.LocalNow())),
CurrentMonth = Date.Month(DateTime.Date(DateTime.LocalNow())),
FilteredDates =
Table.SelectRows(
Dates,
each [Date] >=
Date.AddYears(CurrentDate,-3) and [Date] <=CurrentDate
),
DateCol = Table.SelectColumns(FilteredDates,"Date"),
YearCol =
Table.AddColumn(
DateCol, "Year", each Date.Year([Date]), Int64.Type
),
MonthNameCol =
Table.AddColumn(
YearCol, "Month Name", each Date.MonthName([Date], type
text
),
YearMonthCol =
Table.AddColumn(
MonthNameCol, "Year-Mo", each Text.From([Year]) & "-" & [Month Name], type text
),
MonthNumberCol =
Table.AddColumn(
YearMonthCol, "Month Number", each Date.Month([Date]), Int64.Type
),
WeekdayNameCol =
Table.AddColumn(
MonthNumberCol, "Weekeday", each Date.DayOfWeekName([Date])
),
DayNumberofWeekCol =
Table.AddColumn(
WeekdayNameCol, "Weekday Number", each Date.EndOfWeek([Date]), Int64.Type
),
YearStatusCol =
Table.AddColumn(YearStatusCol, "Year Status", each if Date.IsInCurrentYear([Date]) = true then "Current Year" else
if [Year] = CurrentYear - 1 then "Prior Year" else "Other Year", type text
),
MonthStatusCol =
Table.AddColumn(YearStatusCol, "Month Status", each if [Year Status] = "Current Year" and [Month Number] = CurrentMonth then "Current Month" else
if [Year] = Date.Year(Date.AddMonths(DateTime.Date(DateTime.LocalNow()),-1)) and [Month Number] = Date.Month(Date.AddMonths(DateTime.Date(DateTime.LocalNow()),-1)) then "Prior Month" else
"Other Month", type text
),
DayInMonthCol =
Table.AddColumn(MonthStatusCol,"Day in Month", each Date.Day([Date])), Int64.Type
),
WeekOfYearCol =
Table.AddColumn(DayInMonthCol,"Week of Year", each Date.WeekOfYear([Date])), Int64.Type
),
WeekOfMonthCol =
Table.AddColumn(WeekOfYearCol,"Week of Month", each Date.WeekOfMonth([Date])), Int64.Type
)

in
WeekOfMonthCol

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @BenTen22 ,

 

At a glance, I can see that at least the last three new columns will fail due to you closing the Table.AddColumn function prematurely. You should remove one of the close brackets after the column formula to allow the type defintion to be an argument within the Table.AddColumn function:

 

BA_Pete_1-1662391371107.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

2 REPLIES 2
BA_Pete
Super User
Super User

Hi @BenTen22 ,

 

At a glance, I can see that at least the last three new columns will fail due to you closing the Table.AddColumn function prematurely. You should remove one of the close brackets after the column formula to allow the type defintion to be an argument within the Table.AddColumn function:

 

BA_Pete_1-1662391371107.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Thankyou Pete, also managed to miss a closing bracket further up. Issue now resolved.

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors