cancel
Showing results for
Did you mean:
Highlighted
Member

## Week of the Month (Calculated Column)

Hello,

I have a Date Dimention table, in which I need to add calculated column (Week_Of) shown below in the image. I tried several IF Then else, but not beign able to do it so far. Can you please help?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super Contributor

## Re: Week of the Month (Calculated Column)

`WeekStarting = DimDate[Date] - WEEKDAY(DimDate[Date]) + 1`

Proud to be a Datanaut!
Super Contributor

## Re: Week of the Month (Calculated Column)

That's an easy enough change. WEEKDAY starts on Sunday by default, but you can change it to start on either Saturday or Monday by changing the second argument.

`WeekStarting = DimDate[Date] - WEEKDAY(DimDate[Date], 2) + 1`

Check out the documentation of WEEKDAY here.

Proud to be a Datanaut!
6 REPLIES 6
Super Contributor

## Re: Week of the Month (Calculated Column)

If you were creating this in the query editor it would be easy. There is a Date.WeekofMonth formula. So I'm going to assume you're writing this in DAX. The easiest way I can think of is to use the WEEKNUM formula, which returns the week number in the year. Subtract the WEEKNUM of the first week of the month from the weeknum of the week you're on, and that gives you the week of the month. Don't use the date of the first of the month though, because you'll mess up on weeks that start at the end of the previous month. Use the date of the last day of the week to find the first weeknum of the month.

```WeekOfMonth = VAR weekending = DimDate[Date] - WEEKDAY(DimDate[Date]) + 7
RETURN WEEKNUM(weekending) - WEEKNUM(DATE(YEAR(weekending), MONTH(weekending), 1)) + 1```

Proud to be a Datanaut!
Member

## Re: Week of the Month (Calculated Column)

@KHorsemanThanks, Yes, I'm doing that in DAX.

Your solution gives me the number of week, which I already have in column Day_Wk_Num.
What I'm looking for is what I have in column "Week_Of", which is basically the date of each week begining date, repeating for each day of that week.

Super Contributor

## Re: Week of the Month (Calculated Column)

`WeekStarting = DimDate[Date] - WEEKDAY(DimDate[Date]) + 1`

Proud to be a Datanaut!
Member

## Re: Week of the Month (Calculated Column)

@KHorsemanso, it is sort of working, but it is starting from Sunday, our work week starts from Monday through Sunday. I have a week day column 1 through 7 in there.

Sorry, I'm new to DAX. I do appreciat eyour help.

Member

## Re: Week of the Month (Calculated Column)

Super Contributor

## Re: Week of the Month (Calculated Column)

That's an easy enough change. WEEKDAY starts on Sunday by default, but you can change it to start on either Saturday or Monday by changing the second argument.

`WeekStarting = DimDate[Date] - WEEKDAY(DimDate[Date], 2) + 1`

Check out the documentation of WEEKDAY here.

Proud to be a Datanaut!

Announcements

Power BI Super User, Greg Deckler, explains

#### Power Platform Summit North America

Register by September 5 to save \$200

#### Back to School Contest

Engage and empower students with Power BI!

#### Watch Sessions On Demand!

Continue your learning in our online communities.

Top Ideas
Top Kudoed Authors
Users Online
Currently online: 38 members 1,039 guests
Recent signins: