Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

Python to Dax help

Hello all,

 

I am currently trying to convert this below code into something that I can paste into DAX and create a new column that reads a date column and returns the fiscal week. To clarify, my Fiscal Year starts the week containing May 1st (Sun -Sat) and operates on 445 calendaring. If anyone could guide me on how to convert it that would be a huge help, thanks.

 

Thanks a ton

 

7 Replies

  • vapid128's avatar
    vapid128
    Solution Specialist

    You need a colnum of dates.

    let us name it to [date].

     

    add 3 colnums:

     

    MMD = MONTH([Date])&"/"&DAY([Date])
     
    weeknum = WEEKNUM([Date])
     
    IsFiscalWeek = "5/1" in CALCULATETABLE(VALUES(Dates2[MMD]),ALLEXCEPT(Dates2,Dates2[weekIndex]))
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi vapid128 

     

    Where does "Dates2[weekIndex] come from? Is that just the original date column? 

    • vapid128's avatar
      vapid128
      Solution Specialist
      Sorry, my mistake.
       
      IsFiscalWeek = "5/1" in CALCULATETABLE(VALUES(Dates2[MMD]),ALLEXCEPT(Dates2,Dates2[weeknum])
      • Anonymous's avatar
        Anonymous
        Not applicable

        vapid128 

         

        When I try to make the IsFiscalWeek column I receive the following error message. I've tried changing Date and MMD value formats but none are working. 

         

        Thanks