cancel
Showing results for
Did you mean:
Regular Visitor

## Only Show Previous Week

Hi,

I have this calc column to only show previous week.

Previous Week =
VAR Current_Week = CALCULATE(MAX([Week]) -1, FILTER(vw_ShiftsAll, vw_ShiftsAll[Date] = TODAY()))
RETURN
IF(vw_ShiftsAll[Week] = Current_Week, "Yes", "No")

Week Begins on Monday - >

Week = WEEKNUM(vw_ShiftsAll[Date],2)

But it's returning dates between 12th March to 17th March.

I expected 11th March to 17th March (Monday to Sunday).

2 ACCEPTED SOLUTIONS

Accepted Solutions
Senior Member

## Re: Only Show Previous Week

It looks good to me. Only difference I see is:

```VAR Current_Week =
CALCULATE (
MAX ( [Week] ) - 1,
FILTER ( vw_ShiftsAll, vw_ShiftsAll[Date] = TODAY () )
)```

versus:

```VAR Current_Week =
CALCULATE (
MAX ( vw_ShiftsAll[Week] ) - 1,
FILTER ( vw_ShiftsAll, vw_ShiftsAll[Date] = TODAY () )
)```

Maybe you have something else going on that needs to be known?

Super User

## Re: Only Show Previous Week

Hey,

this DAX statement works in my calendar tables:

```isInPreviousWeek =
var someTestDate = today() -7
var SoWDatePrevWeek = someTestDate  - WEEKDAY(someTestDate,2) + 1
var SoWDate = 'Calendar'[Date]  - WEEKDAY('Calendar'[Date],2) + 1
return
IF(SoWDatePrevWeek = SoWDate, 1,0)```

Basically I use this statement to flag some days in my calendar table with flags like

-1 for the previous week

0 for the current week

1 for the upcoming week

Regards,
Tom

Hamburg - Germany
If I answer you question, please mark my post as solution, this will also help others.
Proud to be a Datanaut!
2 REPLIES 2
Senior Member

## Re: Only Show Previous Week

It looks good to me. Only difference I see is:

```VAR Current_Week =
CALCULATE (
MAX ( [Week] ) - 1,
FILTER ( vw_ShiftsAll, vw_ShiftsAll[Date] = TODAY () )
)```

versus:

```VAR Current_Week =
CALCULATE (
MAX ( vw_ShiftsAll[Week] ) - 1,
FILTER ( vw_ShiftsAll, vw_ShiftsAll[Date] = TODAY () )
)```

Maybe you have something else going on that needs to be known?

Super User

## Re: Only Show Previous Week

Hey,

this DAX statement works in my calendar tables:

```isInPreviousWeek =
var someTestDate = today() -7
var SoWDatePrevWeek = someTestDate  - WEEKDAY(someTestDate,2) + 1
var SoWDate = 'Calendar'[Date]  - WEEKDAY('Calendar'[Date],2) + 1
return
IF(SoWDatePrevWeek = SoWDate, 1,0)```

Basically I use this statement to flag some days in my calendar table with flags like

-1 for the previous week

0 for the current week

1 for the upcoming week

Regards,
Tom

Hamburg - Germany
If I answer you question, please mark my post as solution, this will also help others.
Proud to be a Datanaut!

Announcements

#### Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

#### Power BI Helps Homeless and Trouble Youth

We spoke with Power BI Super User, Greg Deckler, about his charity work

#### Watch Sessions On Demand!

Continue your learning in our online communities.

Top Kudoed Authors
Users Online
Currently online: 40 members 1,131 guests
Recent signins: