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

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 tonCode Logic.PNG

 

7 REPLIES 7
Anonymous
Not applicable

Hi @vapid128 

 

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

Sorry, my mistake.
 
IsFiscalWeek = "5/1" in CALCULATETABLE(VALUES(Dates2[MMD]),ALLEXCEPT(Dates2,Dates2[weeknum])
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

WeekNum Error.PNG

 

IsFiscalWeek = "5/1" in 
CALCULATETABLE(
    VALUES(Dates2[MMD]),
    ALLEXCEPT(Dates2,Dates2[weeknum])
)
 
 
And you date colnum should not skip in date 
 
Anonymous
Not applicable

I've made the changes and it just returns false. I've tried every different formatting option but it still returns False each time

False.PNG

We need all date in date colnum.

If we cant have all date, we can create a date table with all date.

 

datetable = CALENDAR(MIN(table[date]),MAX(table[date]))

vapid128
Solution Specialist
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]))

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.

Top Solution Authors