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
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
v-yuezhe-msft
Employee
Employee

@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

Community Support Team _ Lydia Zhang
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-yuezhe-msft
Employee
Employee

@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

Community Support Team _ Lydia Zhang
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.