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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Bexx
New Member

Bringing back dates of occurrences within set weeks of a month

Good morning, I'm new to power BI and need to be able to bring back attendances within specified weeks in a month - i.e. week 1 

So if the week 1 commencement date is 20/06/2022 and the attendance is 24/06/2022 it will appear in week 1 but if it's 28/06/2022 it will appear in the week 2 column, does anyone know how to do this?

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test. The steps useful for you start from #"Added Custom"

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCs7NLMlQ0lEy0zcyACIjI6VYnWgl54zEopzUYoi4GULcJ7M4ESJojqw4taioEiJsgaQ2NR8oZq5vaAoViwUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Student = _t, Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Student", type text}, {"Date", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each "Week "&Text.From(Number.RoundUp((Duration.Days([Date]-#date(2022,6,19)))/7,0))),
    #"Pivoted Column" = Table.Pivot(#"Added Custom", List.Distinct(#"Added Custom"[Custom]), "Custom", "Date")
in
    #"Pivoted Column"

 

View solution in original post

1 REPLY 1
Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test. The steps useful for you start from #"Added Custom"

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCs7NLMlQ0lEy0zcyACIjI6VYnWgl54zEopzUYoi4GULcJ7M4ESJojqw4taioEiJsgaQ2NR8oZq5vaAoViwUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Student = _t, Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Student", type text}, {"Date", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each "Week "&Text.From(Number.RoundUp((Duration.Days([Date]-#date(2022,6,19)))/7,0))),
    #"Pivoted Column" = Table.Pivot(#"Added Custom", List.Distinct(#"Added Custom"[Custom]), "Custom", "Date")
in
    #"Pivoted Column"

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.