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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Token Comma Expected

Hi all i keep getting the error Token Comma Expected from this query, i cant figure out where the comma is supposed to be. 
 
 
Calendar =
GENERATE (
CALENDAR( DATE( 2016,1,1 ) , TODAY()),
VAR startOfWeek = 1 // Where 1 is Sunday and 7 is Saturday, thus a 3 would be Tuesday
VAR currentDay = [Date]
VAR days = DAY( currentDay )
VAR months = MONTH ( currentDay )
VAR years = YEAR ( currentDay )
VAR nowYear = YEAR( TODAY() )
VAR nowMonth = MONTH( TODAY() )
VAR todayNum = WEEKDAY( TODAY() )
RETURN ROW (
"day", days,
"month", months,
"year", years,
"month index", INT( (years - nowYear ) * 12 + months - nowMonth ),
"year index", INT( years - nowYear )
)
)
4 REPLIES 4
mahoneypat
Microsoft Employee
Microsoft Employee

I put your expression into DAXFormatter.com and it didn't give an error (or fixed it automatically).  Here it is:

 

Calendar =
GENERATE (
CALENDAR ( DATE ( 2016, 1, 1 ), TODAY () ),
VAR startOfWeek = 1 // Where 1 is Sunday and 7 is Saturday, thus a 3 would be Tuesday
VAR currentDay = [Date]
VAR days =
DAY ( currentDay )
VAR months =
MONTH ( currentDay )
VAR years =
YEAR ( currentDay )
VAR nowYear =
YEAR ( TODAY () )
VAR nowMonth =
MONTH ( TODAY () )
VAR todayNum =
WEEKDAY ( TODAY () )
RETURN
ROW (
"day", days,
"month", months,
"year", years,
"month index", INT ( ( years - nowYear ) * 12 + months - nowMonth ),
"year index", INT ( years - nowYear )
)
)

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

I still get the error message. 

Hi @Anonymous @mahoneypat 

I don't get any error.

Could you share error message with me?

Capture6.JPG

Try use ";" to replace "," in your query and check if it is correct.

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Weird.  I put it in Power BI and generated your Calendar table w/o error.

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.