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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MAruna
Frequent Visitor

I need Display week as series

Hi All,

 

I need Assistence on this

 

I have Date column, in that i need to present weeks as

 

May 1 to 7 

May 8 to 14 

May 15 to 21

May 22 to 28 

May 29 to June 4 Like this

 

Thank you for in Advance.

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

It is for creating a calendar table like below.

 

Jihwan_Kim_0-1685540553804.png

 

 

New calendar table = 
VAR _t =
    ADDCOLUMNS (
        CALENDAR ( DATE ( 2023, 1, 1 ), DATE ( 2023, 12, 31 ) ),
        "Year-Week",
            IF (
                MONTH ( [Date] ) = 1
                    && WEEKNUM ( [Date], 21 ) > 50,
                YEAR ( [Date] ) - 1 & "-"
                    & WEEKNUM ( [Date], 21 ),
                YEAR ( [Date] ) & "-"
                    & WEEKNUM ( [Date], 21 )
            )
    )
VAR _weekcolumn =
    ADDCOLUMNS (
        _t,
        "weekcolumn",
            IF (
                MONTH ( MINX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ) )
                    = MONTH ( MAXX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ) ),
                FORMAT (
                    MINX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ),
                    "mmm-dd"
                ) & " to "
                    & FORMAT (
                        MAXX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ),
                        "dd"
                    ),
                FORMAT (
                    MINX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ),
                    "mmm-dd"
                ) & " to "
                    & FORMAT (
                        MAXX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ),
                        "mmm-dd"
                    )
            )
    )
RETURN
    _weekcolumn

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Thank you @Jihwan_Kim ,

 

I have already Date column.

 

Hi,

Thank you for your message, if you already have a date column, and if your expected outcome is to create an additinal column in the same table, please check the below picture and the attached pbix file.

Thank you.

 

Jihwan_Kim_0-1685588979417.png

 

WeekColumn CC =
VAR _t =
    ADDCOLUMNS (
        'Calendar',
        "Year-Week",
            IF (
                MONTH ( [Date] ) = 1
                    && WEEKNUM ( [Date], 21 ) > 50,
                YEAR ( [Date] ) - 1 & "-"
                    & WEEKNUM ( [Date], 21 ),
                YEAR ( [Date] ) & "-"
                    & WEEKNUM ( [Date], 21 )
            )
    )
VAR _weekcolumn =
    ADDCOLUMNS (
        _t,
        "weekcolumn",
            IF (
                MONTH ( MINX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ) )
                    = MONTH ( MAXX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ) ),
                FORMAT (
                    MINX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ),
                    "mmm-dd"
                ) & " to "
                    & FORMAT (
                        MAXX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ),
                        "dd"
                    ),
                FORMAT (
                    MINX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ),
                    "mmm-dd"
                ) & " to "
                    & FORMAT (
                        MAXX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ),
                        "mmm-dd"
                    )
            )
    )
RETURN
    SUMMARIZE (
        FILTER ( _weekcolumn, 'Calendar'[Date] = EARLIER ( 'Calendar'[Date] ) ),
        [weekcolumn]
    )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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