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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Datagulf
Responsive Resident
Responsive Resident

Help clear the error 'The following syntax error occurred during parsing: Invalid token, Line 16, '

I am adding a Fiscal week column to a date table.  (Begins Aprils)
The formula is quite extensive and is as below. 

 

 

Week No = 
--Inputs--
VAR WeekStartsOn = "Sun"
VAR FiscalStartMonth = 4

--Calculation--
VAR FiscalFirstDay = 
    IF(
        MONTH('Calendar_Entry_Date'[Date]) < FiscalStartMonth,
        DATE(
            YEAR('Calendar_Entry_Date'[Date])-1,
            FiscalStartMonth,
            1
        ),
        DATE(
            YEAR('Calendar_Entry_Date'[Date]),
            FiscalStartMonth,
            1
        )
    )
VAR FilteredTableCount = 
    COUNTROWS(
        FILTER(
            SELECTCOLUMNS(
                GENERATESERIES(
                    FiscalFirstDay,
                    'Calendar_Entry_Date'[Date]
                ),
                "Dates",
                [Value]
            ),
        FORMAT([Dates],"ddd") = WeekStartsOn
        )
    )
VAR WeekNos = 
    IF(
        FORMAT(FiscalFirstDay,"ddd") <> WeekStartsOn, 
        FilteredTableCount + 1,
        //1 + WEEKNUM ( 'Calendar'[Date] )-WEEKNUM( STARTOFMONTH ('Calendar'[Date])),
        //WEEKNUM([Date])
        FilteredTableCount
        
    )
RETURN
    WeekNos
      
    

 

 


The issue is I get the error. 

 

 

The following syntax error occurred during parsing: Invalid token, Line 16, Offset 3,  .

 

 

 

What would be issue? 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Datagulf , if just need Sunday when the year started 1-April

 

New COlumn =

var _StYear = date(if(month([Date]) <4, Year([Date]) -1, Year([Date]) ),4,1)

return

_StYear - weekday(_StYear ,1) +1

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Datagulf , if just need Sunday when the year started 1-April

 

New COlumn =

var _StYear = date(if(month([Date]) <4, Year([Date]) -1, Year([Date]) ),4,1)

return

_StYear - weekday(_StYear ,1) +1

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

This works for me. @amitchandak 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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