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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
abegum
Frequent Visitor

CLYCLICAL WEEKS IN POWERBI/POWERQUERY

Good day,
I have a list of weeks of the year and I want to group them into groups of 5, for example:
-week 1: 1,2,3,4,5
-week 2: 2,3,4,5,6
The problem I have is that when I get to the last weeks, I wish that when I get to 53, I go back to the beginning, for example:
-week 50: 51,52,53,1,2
-week 51: 51,52,53,1,2,3
Is there a way to do it by powerquery?
In other words I want the list to be cyclical

abegum_0-1635437404496.png

 

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

 

let
    Source = {1..53},
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Added Custom" = Table.AddColumn(#"Converted to Table", "Custom", each List.Range(Source & Source,[Column1]-1,5)),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text})
in
    #"Extracted Values"

 

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

 

let
    Source = {1..53},
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Added Custom" = Table.AddColumn(#"Converted to Table", "Custom", each List.Range(Source & Source,[Column1]-1,5)),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text})
in
    #"Extracted Values"

 

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.