nemd
nemd

Reputation: 33

Define last week from [date]

I have issue extracting week/year from DATE column.

We are in week 02 of 2022 and my goal is to set MAX week to be "01 2022" at the moment.

Goal is to have dynamic calculated column or measure that will always show previous week.

weekMax = FORMAT(MAX(fact[date]),"WW YYYY")

With this solution it is showing me 03 2022 result.

Is there a way to sort this out?

Upvotes: 1

Views: 913

Answers (1)

Marco_CH
Marco_CH

Reputation: 3294

You could try something like:

weekMax = 
VAR lastweek = FORMAT(DATEADD('Table'[Date].[Date], -7, DAY) ,"WW YYYY")

RETURN
IF(FORMAT(TODAY() - 7 ,"WW YYYY") = lastweek, lastweek, BLANK())

Output:

enter image description here


Or if you always just want the last week without considering any columns, you can use:

weekMax = FORMAT(TODAY() - 7 ,"WW YYYY")

Upvotes: 2

Related Questions