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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

unabe to use WEEKNUM or DATEPART in sql + direct query

I'm trying to get directly from the database:

DATE and weekday (monday, tuesday) or in number (1,2)

When I insert the DATEPART formula PBI gives me an error (incompatible query)

 

If I only insert the date and try to transform it in day of week, it throws another error abount incompatibility of the function in Direct Query.

 

I'm working on an online dashboard (that's why I use DirectQuery), any ideas of how can get this data?

The other solution is to have a script that copies the data to another database with all the transformations and then use direct query from there, but it seems messy.

 

Any idea?

Thank you!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Anonymous,

You can create the following calculated columns in your table. If the DAX don't return your expected result, please share sample data of your column and post your desired result here.

weeknumber = WEEKNUM(YourTable[Date])
weekday = WEEKDAY(YourTable[Date])

1.PNG

Regards,
Lydia

View solution in original post

1 REPLY 1
Anonymous
Not applicable

@Anonymous,

You can create the following calculated columns in your table. If the DAX don't return your expected result, please share sample data of your column and post your desired result here.

weeknumber = WEEKNUM(YourTable[Date])
weekday = WEEKDAY(YourTable[Date])

1.PNG

Regards,
Lydia

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors