Forum Discussion

pstanek's avatar
pstanek
Icon for Post Patron rankPost Patron
10 years ago

Need help creating number of week

Hi I use direct query within Power BI  and WEEKNUM doesn´t work because Calculated column dax formrmula doesn´t support WEEKNUM in direct query. How can I calculate it within direct Query?

 

I have column with dates and I need to add column with week number.

6 Replies

  • ankitpatira's avatar
    ankitpatira
    Icon for Community Champion rankCommunity Champion

    pstanek I cannot replicate your issue. I have directquery to sql server and can successfully create calc column with WEEKNUM function. Ensure you have latest version of pbi desktop and go to File -> Options and Settings -> Options and check that you have allow unrestricted measure ticked.

     

  • v-sihou-msft's avatar
    v-sihou-msft
    Icon for Microsoft Employee rankMicrosoft Employee

     pstanek

     

    I reproduced same issue as yours, my power bi desktop version is 2.36.4434.381. Even I enable "unrestricted measures" in DirectQuery Option, I still get "not supported" error when adding a calculated column to get the week number from SQL table date column. 

    I suggest you use DATEPART() get the week number on T-SQL query level. 

     

    Regards,

    • pstanek's avatar
      pstanek
      Icon for Post Patron rankPost Patron

      Where can I find T SQL level?

       

      File -> Options and Settings -> Options and check that you have allow unrestricted measure ticked.

      Is this safe? I am afraid of incorrect results.

       

    • elliotdixon's avatar
      elliotdixon
      Icon for Responsive Resident rankResponsive Resident

      Hi v-sihou-msft how did you get on with finding a solution to this? I have allowed the unrestricted measures but still cannot get the WEEKNUM working on Direct Query mode.

       

       

      Cheers,

      ED.

    • alme's avatar
      alme
      Icon for Helper I rankHelper I

      No news? Have the same problem