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
Raks
Helper III
Helper III

Finding date using Weeknum Weekday and Year

Hi Team,

I have weeknumber column WeekDay Colum and Year column, I have to find date for this.

Can you please help me.

 

Thanks!

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @Raks ,

According to your description, here's my solution, create a column.

Column =
VAR _firstweek =
    7 - WEEKDAY ( DATE ( [Year], 1, 1 ) ) + 1
VAR _between = ( [Week] - 1 ) * 7
VAR _lastweek =
    SWITCH (
        [WeekDay],
        "Monday", 1,
        "Tuesday", 2,
        "Wedsday", 3,
        "Thursday", 4,
        "Friday", 5,
        "Saturday", 6,
        "Sunday", 7
    )
RETURN
    DATE ( [Year], 1, 1 ) + _firstweek + _between + _lastweek

Get the correct result:

vyanjiangmsft_0-1685094312774.png

I attach my sample below for your reference.

 

Best regards,

Community Support Team_yanjiang

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

 

View solution in original post

6 REPLIES 6
v-yanjiang-msft
Community Support
Community Support

Hi @Raks ,

According to your description, here's my solution, create a column.

Column =
VAR _firstweek =
    7 - WEEKDAY ( DATE ( [Year], 1, 1 ) ) + 1
VAR _between = ( [Week] - 1 ) * 7
VAR _lastweek =
    SWITCH (
        [WeekDay],
        "Monday", 1,
        "Tuesday", 2,
        "Wedsday", 3,
        "Thursday", 4,
        "Friday", 5,
        "Saturday", 6,
        "Sunday", 7
    )
RETURN
    DATE ( [Year], 1, 1 ) + _firstweek + _between + _lastweek

Get the correct result:

vyanjiangmsft_0-1685094312774.png

I attach my sample below for your reference.

 

Best regards,

Community Support Team_yanjiang

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

 

Raks
Helper III
Helper III

@rajulshah  I want to create a date colum based on weeknum weekday and year

 

 

thanks !

@Raks 

So instead of variables, you can use the columns in it. Please let me know if you find any issues.

rajulshah
Super User
Super User

@Raks 
Can you provide the sample data and output?

@rajulshah 

Sample data is 

Week  WeekDay Year Req_Result

41       Tuesday   2022       11/10/2023(DD_MM_YYYY)

 

@Raks 
I have created a measure as follows. Maybe this can help you to reach what you need.

SelectedDate =
VAR DateTable =
    CALENDARAUTO ()
VAR WeekNumber = 41
VAR WeekDayValue = "Tuesday"
VAR YearValue = 2023
RETURN
    MINX (
        FILTER (
            DateTable,
            FORMAT ( [Date], "dddd" ) = WeekDayValue
                && WEEKNUM ( [Date] ) = WeekNumber
                && YEAR ( [Date] ) = YearValue
        ),
        [Date]
    )

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.