cancel
Showing results for
Did you mean:
Highlighted

## Week Start calculation

I'd love to be able to group my dates into Week Start buckets. In Qlikview there is a WeekStart() function where you provider a date and it groups dates into weeks, depending on the date and offset you provider so you can easily do this. I'm not finding something similar in PBI yet. Does anyone know how to do this?  Basically looking to add 1 new column to my calendar table. I already have the weeks numbered, but I need the "display" value now so we'd see thing slike 6/2/2018, 6/9/2018, 6/16/2018 and so on as the labels.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

## Re: Week Start calculation

Ok...so this appears to work and do what I need:

WeekStart

WeekStart_WeekEnd

= Table.AddColumn(#"WeekStart_WeekEnd", each Date.ToText(Date.StartOfWeek([Date], Day.Sunday),"MM/dd/yyyy") & "-" & Date.ToText(Date.EndOfWeek([Date], Day.Sunday),"MM/dd/yyyy"))

I'll leave this here so the next person trying this can hopefully find it and not bang their head for a full day.

I appreciate all the help.

13 REPLIES 13
Highlighted
Super User IX

## Re: Week Start calculation

You should be able to use a variation of my Week Starting Quick Measure here:

https://community.powerbi.com/t5/Quick-Measures-Gallery/Week-Starting/m-p/391487

---------------------------------------

##### I have a NEW book! DAX Cookbook from Packt
Over 120 DAX Recipes!

Proud to be a Super User!

Highlighted
Resident Rockstar

## Re: Week Start calculation

Hi

The below Dax will help to get the week start date. I am assuming that Sunday is your week start date.

WeekStartDate = Sheet2[Date]-  WEEKDAY(Sheet2[Date],1)+1  // Sunday as Week start date

WeekStartDate = Sheet2[Date]-  WEEKDAY(Sheet2[Date],2)+1 // Monday as Week start date

Hope this is what you are looking for.

Thansk
Raj

Highlighted

## Re: Week Start calculation

Is there a way to do it in the Query Editor? I'm using the "Ultimate Calendar" query load and am wondering if can just be added there instead of DAX so all the Date Logic is on the calendar. We are just looking for a Sunday start yes. Is that possible do you know?

Highlighted
Super User IX

## Re: Week Start calculation

I have personally found that instead of dealing with dates in the Query Editor that it is instead preferrable to bash my head repeatedly into a brick wall until I pass out from blood loss and forget that I was trying to attempt something so foolish. But @ImkeF might be able to assist.

---------------------------------------

##### I have a NEW book! DAX Cookbook from Packt
Over 120 DAX Recipes!

Proud to be a Super User!

Highlighted

## Re: Week Start calculation

Haha...but if I have a nice Calendar query, I can simply copy it from one report to the next when I create them. Adding in a DAX measure would add 1 more step would it not? Not the end of the world but I'm trying to keep things simple and tidy. Maybe I'm just missing something but that's the goal anyway.

Highlighted
Super User IX

## Re: Week Start calculation

No, I absolutely get it. I'm just saying that dealing with dates in M code can be incredibly frustrating.

---------------------------------------

##### I have a NEW book! DAX Cookbook from Packt
Over 120 DAX Recipes!

Proud to be a Super User!

Highlighted

## Re: Week Start calculation

I'm definitely starting to feel the same way...

Highlighted

## Re: Week Start calculation

Ok...so this appears to work and do what I need:

WeekStart

WeekStart_WeekEnd

= Table.AddColumn(#"WeekStart_WeekEnd", each Date.ToText(Date.StartOfWeek([Date], Day.Sunday),"MM/dd/yyyy") & "-" & Date.ToText(Date.EndOfWeek([Date], Day.Sunday),"MM/dd/yyyy"))

I'll leave this here so the next person trying this can hopefully find it and not bang their head for a full day.

I appreciate all the help.

Highlighted
Frequent Visitor

## Re: Week Start calculation

Can you please help me understand how to use your DAX example?  Is it for a column or Table or Measure?   Is Sheet2 the name of the table?  and [Date] the name of the Date field in the Table?  I am unable to figure out how to get it to work.

Announcements

#### Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

#### August Community Highlights

Check out a full recap of the month!

#### Community Summit North America – Join Online!

Join this community-driven Power Platform digital event for unbiased support and problem-solving.

#### Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.

#### Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Top Solution Authors
Top Kudoed Authors