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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Getting the earliest modified Date

Hi,

 

I have a file that lists the Field Ticket Number and Modified Date. I would like to create a new field called FirstModifiedDate.

One ticket number can have multiple line items:

 

Ticket#  ModifiedDate

181234 12/5/2019

181234 12/4/2019

181234 12/5/2019

181235 12/5/2019

181235 12/4/2019

181235 12/3/2019

 

I would like my output as follows:

 

Ticket#  ModifiedDate FirstModifiedDate

181234 12/5/2019 12/4/2019 

181234 12/4/2019 12/4/2019 

181234 12/5/2019 12/4/2019 

181235 12/5/2019 12/3/2019

181235 12/4/2019 12/3/2019

181235 12/3/2019 12/3/2019

 

What do I need to do in Power Query?

1 ACCEPTED SOLUTION
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can use group for one time and then expand the result to meet your requirement:

 

5.jpg6.jpg7.jpg

 

All the quries are here:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrQwNDI2UdJRMjTSN9U3MjC0VIrVQRU2wS6MrtoUrzC6IVBhY6hwLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Ticket#" = _t, ModifiedDate = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Ticket#", Int64.Type}, {"ModifiedDate", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Ticket#"}, {{"Data", each _, type table [#"Ticket#"=number, ModifiedDate=date]}, {"FirstModifiedDate", each List.Min([ModifiedDate]), type date}}),
    #"Expanded Data" = Table.ExpandTableColumn(#"Grouped Rows", "Data", {"ModifiedDate"}, {"Data.ModifiedDate"}),
    #"Renamed Columns" = Table.RenameColumns(#"Expanded Data",{{"Data.ModifiedDate", "ModifiedDate"}})
in
    #"Renamed Columns"

 


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can use group for one time and then expand the result to meet your requirement:

 

5.jpg6.jpg7.jpg

 

All the quries are here:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrQwNDI2UdJRMjTSN9U3MjC0VIrVQRU2wS6MrtoUrzC6IVBhY6hwLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Ticket#" = _t, ModifiedDate = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Ticket#", Int64.Type}, {"ModifiedDate", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Ticket#"}, {{"Data", each _, type table [#"Ticket#"=number, ModifiedDate=date]}, {"FirstModifiedDate", each List.Min([ModifiedDate]), type date}}),
    #"Expanded Data" = Table.ExpandTableColumn(#"Grouped Rows", "Data", {"ModifiedDate"}, {"Data.ModifiedDate"}),
    #"Renamed Columns" = Table.RenameColumns(#"Expanded Data",{{"Data.ModifiedDate", "ModifiedDate"}})
in
    #"Renamed Columns"

 


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

I had no idea this was possible....I just did a calculated column.

Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

 

for this you need some coding and use a Table.Group with List.Min function and a NestedJoin to join the result to your original table.

Here the complete solution

let
	Source = #table
	(
		{"Ticket#","ModifiedDate"},
		{
			{"181234","43597"},	{"181234","43567"},	{"181234","43597"},	{"181235","43597"},	{"181235","43567"},	{"181235","43536"}
		}
	),
    ToDate = Table.TransformColumns
    (
        Source,
        {
            {
                "ModifiedDate",
                each Date.From(Number.From(_)),
                type date
            }
        }
    ),
    Group = Table.Group
    (
        ToDate,
        {"Ticket#"},
        {
            {
                "MaxDate",
                each List.Min(_[ModifiedDate]),
                type date
            }
        }
            
    ),
    NestedJoin = Table.NestedJoin
    (
        ToDate,
        "Ticket#",
        Group,
        "Ticket#",
        "MaxDate"

    ),
    Expand = Table.ExpandTableColumn(NestedJoin, "MaxDate", {"MaxDate"}, {"MaxDate"})
in
	Expand

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works. If this solution fits your need, copy and past a part of it and implement it in your query.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

 

Anonymous
Not applicable

Was I not clear?

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.