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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
spandy34
Responsive Resident
Responsive Resident

Group by Weeks

Hello

 

I have a Date Table and I would like to create a column named Qtr/Weeks which groups the Week Nos by 12 , so each Qtr Week contains 12 weeks ie

 

Qtr/Weeks          WeekNo

1                            0-11

2                           12-23

3                           24-35

4                           36-47

5                           48-52

spandy34_1-1714069194741.png

 

Can someone please tell me how to create this column in the table below.

 

Many thanks

@v-heq-msft @Greg_Deckler @danextian @tamerj1 @goncalogeraldes 

2 ACCEPTED SOLUTIONS
danextian
Super User
Super User

Hi @spandy34 ,

Please try:

danextian_0-1714112654721.png

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

Hi @spandy34 ,


Does the reference week number reset? If the, the formula i proposed would reset as well.
I dont know how you number your weeks but the sample formula below calculates for the week number from a reference up to the current row date.

Week number from start =
QUOTIENT ( DATEDIFF ( DATE ( 2022, 1, 1 ), 'Calendar'[Date], DAY ), 7 ) + 1

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

11 REPLIES 11
danextian
Super User
Super User

Hi @spandy34 ,

Please try:

danextian_0-1714112654721.png

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

hI @danextian 

 

This works if I use 

Qtr = ROUNDUP(DIVIDE('Procurement_Delivered_Visit_Date'[WeekNo],12),0) but it still resets at the end of the year as mentioned and I need to be continuous and not reset and going back to 1 at the beginning of the new year so for Date 01 January 2024 the 12 Weeks Period has gone back to 1 but there are not 12 weeks in Period 5.  How do I get the column so it just rolls on without returning back to 1 for a new year?

Hi @spandy34 ,


Does the reference week number reset? If the, the formula i proposed would reset as well.
I dont know how you number your weeks but the sample formula below calculates for the week number from a reference up to the current row date.

Week number from start =
QUOTIENT ( DATEDIFF ( DATE ( 2022, 1, 1 ), 'Calendar'[Date], DAY ), 7 ) + 1

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

You are correct - I looked at the source of the Week Nos column and it was resetting after each year back to 1 so I have used the following DAX for the Week Nos and it is continuous.  I then used the calculation you provided for the grouping and it has worked .  The DAX for the two columns are below.  Thank you for your help

 

WeekNos = QUOTIENT( datediff(minx('Procurement_Delivered_Visit_Date',[Date]),[Date],DAY),7)+1

 

12 Weeks Period = ROUNDUP(DIVIDE('Procurement_Delivered_Visit_Date'[WeekNos],12),0)

 

Hi @danextian 

 

I  added the column you suggested and it worked great apart from  the 12 Weeks Period is  going back to 1 at the beginning of the new year so for Date 01 January 2024 the 12 Weeks Period has gone back to 1 but there are not 12 weeks in Period 5.  How do I get the column so it just rolls on without returning back to 1 for a new year?

 

spandy34_0-1715007873836.png

 


@danextian wrote:

Hi @spandy34 ,

Please try:

danextian_0-1714112654721.png

 


 

That is brilliant. It worked.  Thank you very much @danextian 

spandy34
Responsive Resident
Responsive Resident

Could this be done by creating the new column if I grouped by every 6 weeks instead of every 12 weeks ?

lbendlin
Super User
Super User

Quarters and weeks are incompatible. Use an external static reference table that clearly identifies the quarter and the week number for every single day.

spandy34
Responsive Resident
Responsive Resident

Could this be done by creating the new column if I grouped by every 6 weeks instead of every 12 weeks ?

Not sure what you mean. Please elaborate.

spandy34
Responsive Resident
Responsive Resident

I just want a new column that says :

 

if the Week No column is between 1 and 11 then 1

if the Week No is between 12 and 23 then 2

if the Week No is between 24 and 35 then 3 and so on 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.