1

I am converting a Spotfire report to Power BI and am stuck with one of the calculated column. I have the below calculation in Spotfire:

when 
([Target Date]>=DateAdd("day",-DayOfWeek(DateTimeNow()),DateTimeNow())) and 
([Target Date]<=DateAdd("Week",8,DateTimeNow())) 
then First([Start of Week]) OVER ([WeekNum],[Year])
else NULL
END

Here I do not understand how to write the then clause First([Start of Week]) OVER ([WeekNum],[Year]) in Power Query or DAX

Would appreciate any help or guidance.

Priyanka2304
  • 200
  • 3
  • 16

1 Answers1

0

From the code snippet you afforded First([Start of Week]) OVER ([WeekNum],[Year]), you are trying to get the Week Start Date for a specific [Target Date] : Using DAX :

YourCalculatedColumn =
    Switch ( True(),
        (
        ([Target Date]>= DateAdd(DateTimeNow(),-DayOfWeek(DateTimeNow()),day) ) 
         && 
        ([Target Date]<= DateAdd(DateTimeNow()),8,day)) ,
        
        [Target Date] – WEEKDAY([Target Date],2) + 1,
        NULL
        )
    
Amira Bedhiafi
  • 8,088
  • 6
  • 24
  • 60