Forum Discussion

caebrida's avatar
caebrida
Regular Visitor
5 years ago
Solved

Line Graph by Week issues moving from 2020 to 2021

Dear colleagues, 

 

I created a dashboard last year to track the helpdesk performance overall over time. 

It's been working until 2021. The reason is I'm using the week number (calculated field) to create a time-based graph to show the total number of tickets per week. With the new year, the week number returned to 01 and broke everything, as you can see below. 

 

 

I'm a noob in PowerBI, can someone suggest a different approach to make this works?

 

 

 

  • Hi caebrida ,

     

    You can probably create a calculated concatenated column to fecth year+week number. That should suffice your requirement. This is the easiest way.

    DAX for New Column:

    Week No = YEAR(TableName[Date_Column]) & " W" & WEEKNUM(TableName[Date_Column],1)

     

    2nd method would be to create indexing so that 2021's Week1 comes after 2020's week53. This method would be a bit lengthy.

     

     

     

    Give a Thumbs Up if this post helped you in any way and Mark This Post as Solution if it solved your query !!!

    Proud To Be a Super User !!!
    LinkedIn

     

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi caebrida 

    I think your problem is that the weeknum will start by 1 again in a new year instead of continuous on the basis of 2020.

    You can build a continuous weeknum by calculated column.

    My Sample:

    Date = 
    ADDCOLUMNS (
        CALENDAR ( DATE ( 2020, 12, 01 ), DATE ( 2021, 02, 01 ) ),
        "Year", YEAR ( [Date] ),
        "WeekNum", WEEKNUM ( [Date], 2 )
    )

    Calculated column:

    Accumulate_Week_Num = 
    IF (
        RANKX ( 'Date', 'Date'[YEAR],, ASC, DENSE ) <> 1,
        SUMX (
            SUMMARIZE (
                FILTER ( 'Date', 'Date'[YEAR] < EARLIER ( 'Date'[YEAR] ) ),
                'Date'[Year],
                "Maxweeknum-1",
                    MAXX (
                        FILTER ( 'Date', 'Date'[YEAR] = EARLIER ( 'Date'[YEAR] )),
                        'Date'[WeekNum]
                    ) - 1
            ),
            [Maxweeknum-1]
        ) + 'Date'[WeekNum],
        WEEKNUM ( 'Date'[Date], 2 )
    )

    Result is as below.

    Best Regards,

    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi caebrida 

    I think your problem is that the weeknum will start by 1 again in a new year instead of continuous on the basis of 2020.

    You can build a continuous weeknum by calculated column.

    My Sample:

    Date = 
    ADDCOLUMNS (
        CALENDAR ( DATE ( 2020, 12, 01 ), DATE ( 2021, 02, 01 ) ),
        "Year", YEAR ( [Date] ),
        "WeekNum", WEEKNUM ( [Date], 2 )
    )

    Calculated column:

    Accumulate_Week_Num = 
    IF (
        RANKX ( 'Date', 'Date'[YEAR],, ASC, DENSE ) <> 1,
        SUMX (
            SUMMARIZE (
                FILTER ( 'Date', 'Date'[YEAR] < EARLIER ( 'Date'[YEAR] ) ),
                'Date'[Year],
                "Maxweeknum-1",
                    MAXX (
                        FILTER ( 'Date', 'Date'[YEAR] = EARLIER ( 'Date'[YEAR] )),
                        'Date'[WeekNum]
                    ) - 1
            ),
            [Maxweeknum-1]
        ) + 'Date'[WeekNum],
        WEEKNUM ( 'Date'[Date], 2 )
    )

    Result is as below.

    Best Regards,

    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

  • Hi caebrida ,

     

    You can probably create a calculated concatenated column to fecth year+week number. That should suffice your requirement. This is the easiest way.

    DAX for New Column:

    Week No = YEAR(TableName[Date_Column]) & " W" & WEEKNUM(TableName[Date_Column],1)

     

    2nd method would be to create indexing so that 2021's Week1 comes after 2020's week53. This method would be a bit lengthy.

     

     

     

    Give a Thumbs Up if this post helped you in any way and Mark This Post as Solution if it solved your query !!!

    Proud To Be a Super User !!!
    LinkedIn

     

  • caebrida's avatar
    caebrida
    Regular Visitor

    Anand and Rico,

     

    Both solutions have worked for me. 

     

    Thank you guys!

    Best,