Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

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

HI @Anonymous,

 

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.

62.gif

 

Regards,
Xiaoxin Sheng

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

View solution in original post

4 REPLIES 4
v-shex-msft
Community Support
Community Support

Hii @Anonymousm,

 

>>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
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

Hi V-shex-msft thanks for reply!

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!

 

HI @Anonymous,

 

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.

62.gif

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

That's is not possible in Power BI?

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.