cancel
Showing results for
Did you mean:
Frequent Visitor

## Period of days between 2 weeks

Hi people!
I need to create an period of days.
I have found several ranges of dates, but of days I have not found yet, my filter is not a fixed date.

Example: Whenever I look at the report, I need to see last week, the current week and the following week.
I created dimension filter with Weeknum (now ()), Weeknum (now ()) - 1, Weeknum (now ()) + 1.
So I bring the period I need. But within these weeks I need to bring the days of the week, which starts on Friday of the previous week, and ends on the monday of the current week and another that starts at the Wednesday of the last week, and ends on the Thursday of the current week for exemple.

Someone have any idea how can i do it?

Thank a lot of!
Luiz Pereira
1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team

## Re: Period of days between 2 weeks

HI @Luiz_Pereira,

You can refer to following steps to achieve your requirement.

Steps:

1. Add WeekNum to original table and create a what if parameter table with index and day of weeks.

``` = WEEKNUM([Date],1)
Calculate table:
Selected = SELECTCOLUMNS(GENERATESERIES(1,7,1),"Index",[Value],"Day of Week",FORMAT([Value],"dddd"))```

2. Write a measure to check weeknum and selected day of week to display detail information.

```Detail =
VAR currWeek =
MAX ( 'Table 2'[weekNum] )
VAR _weeknow =
WEEKNUM ( TODAY (), 1 )
VAR inRange =
IF (
MAX ( 'Table 2'[Date] )
IN CALCULATETABLE (
VALUES ( 'Table 2'[Date] ),
FILTER (
ALLSELECTED ( 'Table 2' ),
'Table 2'[weekNum]
IN {
_weeknow - 1,
_weeknow,
_weeknow + 1
}
&& YEAR ( 'Table 2'[Date] ) = YEAR ( MAX ( 'Table 2'[Date] ) )
)
),
"Y",
BLANK ()
)
VAR selectedIndex =
SELECTEDVALUE ( 'Selected'[Index] )
RETURN
IF (
inRange <> BLANK (),
CONCATENATEX (
FILTER (
VALUES ( 'Table 2'[Date] ),
IF (
currWeek
= _weeknow - 1,
WEEKDAY ( [Date], 1 ) >= selectedIndex,
IF ( currWeek = _weeknow, WEEKDAY ( [Date], 1 ) < selectedIndex )
)
),
FORMAT ( [Date], "dddd" ),
","
)
)
```

3. Create table visual and slicer to show correspondent graph.

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

For learning resources/Release notes, please visit: | |
4 REPLIES 4
Highlighted
Community Support Team

## Re: Period of days between 2 weeks

Hii @Luiz_Pereiram,

>>So I bring the period I need. But within these weeks I need to bring the days of the week, which starts on Friday of the previous week, and ends on the monday of the current week and another that starts at the Wednesday of the last week, and ends on the Thursday of the current week for exemple.

I'm not so clear for your description, can you please explain more about these with expected result?

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

For learning resources/Release notes, please visit: | |
Frequent Visitor

## Re: Period of days between 2 weeks

So, i need to bring 3 weeks, current week, previous week and next week, always.

Example considering our current date.
W2 January (day 6 to 12, week Previous).
W3 January (day 13 to 19, us current week),
W4 January (day 20 to 26, next week)

After that, i need to bring the day range with the day name of de week.
So here theres my problem, because, i need to make some ranges:

Exemple: A filter with start ever on Tuesday of the W2 and ends ever Wednesday of W3.
So if we have this.
W2: Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday.
W3: Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday.
W4: Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday.

The filter need to bring this
W2: Tuesday, Wednesday, Thursday, Friday, Saturday.
W3: Sunday, Monday, Tuesday, Wednesday.

Thanks for helping!

Frequent Visitor

## Re: Period of days between 2 weeks

That's is not possible in Power BI?

Community Support Team

## Re: Period of days between 2 weeks

HI @Luiz_Pereira,

You can refer to following steps to achieve your requirement.

Steps:

1. Add WeekNum to original table and create a what if parameter table with index and day of weeks.

``` = WEEKNUM([Date],1)
Calculate table:
Selected = SELECTCOLUMNS(GENERATESERIES(1,7,1),"Index",[Value],"Day of Week",FORMAT([Value],"dddd"))```

2. Write a measure to check weeknum and selected day of week to display detail information.

```Detail =
VAR currWeek =
MAX ( 'Table 2'[weekNum] )
VAR _weeknow =
WEEKNUM ( TODAY (), 1 )
VAR inRange =
IF (
MAX ( 'Table 2'[Date] )
IN CALCULATETABLE (
VALUES ( 'Table 2'[Date] ),
FILTER (
ALLSELECTED ( 'Table 2' ),
'Table 2'[weekNum]
IN {
_weeknow - 1,
_weeknow,
_weeknow + 1
}
&& YEAR ( 'Table 2'[Date] ) = YEAR ( MAX ( 'Table 2'[Date] ) )
)
),
"Y",
BLANK ()
)
VAR selectedIndex =
SELECTEDVALUE ( 'Selected'[Index] )
RETURN
IF (
inRange <> BLANK (),
CONCATENATEX (
FILTER (
VALUES ( 'Table 2'[Date] ),
IF (
currWeek
= _weeknow - 1,
WEEKDAY ( [Date], 1 ) >= selectedIndex,
IF ( currWeek = _weeknow, WEEKDAY ( [Date], 1 ) < selectedIndex )
)
),
FORMAT ( [Date], "dddd" ),
","
)
)
```

3. Create table visual and slicer to show correspondent graph.

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

For learning resources/Release notes, please visit: | |

Announcements

#### Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

#### Community News & Announcements

Get your latest community news and 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.

#### Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Top Kudoed Authors
Users Online
Currently online: 46 members 1,107 guests
Recent signins: