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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Rygar
Helper II
Helper II

Find start date of week and repeat the date

Dear Community,

 

i have a Column with ascending dates and need the starting date of each week in a second column:

Bild1.png

I need this in Power Query. Example File here.

Thanks and regards, Michael

1 ACCEPTED SOLUTION
m_alireza
Solution Specialist
Solution Specialist

Hi @Rygar ,

Create a Custom Column in Power Query and enter this: 

=Date.StartOfWeek([From this], Day.Monday)


where [From this] equals name of your date column

View solution in original post

4 REPLIES 4
AntrikshSharma
Community Champion
Community Champion

@Rygar Use this:

let
    Source = Table.FromRows (
        Json.Document (
            Binary.Decompress (
                Binary.FromText (
                    "Vc67DcAwDAPRXVwHkER/Ys1ieP81DBdByPJVd2uVaUiDA2U/V9VF8StNAEZlNEZnDMbLmIyUqIt0SCZCLuLb2Ac=",
                    BinaryEncoding.Base64
                ),
                Compression.Deflate
            )
        ),
        let
            _t = ( ( type nullable text ) meta [ Serialized.Text = true ] )
        in
            type table [ #"From this" = _t ]
    ),
    ChangedType = Table.TransformColumnTypes ( Source, { { "From this", type date } } ),
    WeekOfYear = 
        Table.AddColumn (
            ChangedType,
            "Week of Year",
            each Date.WeekOfYear ( [From this], Day.Monday ),
            Int64.Type
        ),
    GroupedRows = 
        Table.Group (
            WeekOfYear,
            { "Week of Year" },
            {
                {
                    "Transformation",
                    ( Dates ) =>
                        Table.AddColumn (
                            Table.RemoveColumns ( Dates, "Week of Year" ),
                            "To this",
                            each List.Min ( Dates[From this] ),
                            type date
                        )
                }
            }
        ),
    RemovedOtherColumns = Table.Combine ( GroupedRows[Transformation] )
in
    RemovedOtherColumns

 

Thanks a lot 4 your support!

 

m_alireza
Solution Specialist
Solution Specialist

Hi @Rygar ,

Create a Custom Column in Power Query and enter this: 

=Date.StartOfWeek([From this], Day.Monday)


where [From this] equals name of your date column

Great! Thanks a lot.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.

Top Solution Authors
Top Kudoed Authors