Forum Discussion

ramkula123's avatar
ramkula123
Helper I
7 years ago

Translate SQL query to DAX

Hi All, 

 

I have a SQL query 

 

DATEDIFF(Week,Getdate(),DATEADD (WEEK, CAST (RIGHT(CAST ([Code] AS nvarchar),2) AS int), DATEADD (YEAR, ([Code] / 100)-1900, 0)) - 4 - DATEPART(dw, DATEADD (WEEK, CAST (RIGHT(CAST ([Code] AS nvarchar),2) AS int), DATEADD (YEAR, ([Code] / 100)-1900, 0)) - 4) + 1) AS [Indicator] 

 

I need to convert this logic and perform it using DAX in PBI .

 

Ex : Code column has values like 201836 ,201837,201838 etc. And the expected value in Indicator column  should be like -33 , -32 ,-31  respectively (depending on the current week which is while using getdate() in SQL)

 

Can anyone help please ?

 

Thank you

 

No RepliesBe the first to reply