'Finding the first date across several columns/rows

I need to find the earliest date across each row. I need the earliest date to be the output in a column.

Is there a DAX formula I can use in a calculated column?

For example, the first row would output "2/15/2020"

enter image description here

Please help, I am very stuck.



Solution 1:[1]

In M Code (powerquery) below Perhaps there is a DAX solution someone will share

To add a column, Method 1: Add an index. Pull the row using the index. Convert that to a list. Find the minimum

let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1),
#"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each List.Min((Record.ToList(Table.SelectColumns(#"Added Index",Table.ColumnNames(Source)){[Index]})))),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", type date}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"Index"})
in #"Removed Columns"

To add a column, Method 2: Group on index, take minimum, paste back into source data

let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Added Index", {"Index"}, "Attribute", "Value"),
#"Grouped Rows" = Table.Group(#"Unpivoted Other Columns", {"Index"}, {{"MinDate", each List.Min([Value]), type date}}),
#"Merged Queries" = Table.NestedJoin(#"Added Index", {"Index"}, #"Grouped Rows", {"Index"}, "Table2", JoinKind.LeftOuter),
#"Expanded Table2" = Table.ExpandTableColumn(#"Merged Queries", "Table2", {"MinDate"}, {"MinDate"}),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded Table2",{{"MinDate", type date}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Index"})
in #"Removed Columns"

Solution 2:[2]

@horseyride has some good suggestions but I think I can simplify it a bit.

Define a new custom column by clicking Add Column > Custom Column and putting in this:

List.Min(Record.ToList(_))

Here's a full sample query you can paste into the Advanced Editor to examine yourself:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WstA3NNM3MjAyVNJRMtc3NIKxgSxDUwgnVidayRDIhEvpmyJ0GBsgFAEFLPWN4EYoxcYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Epic GoLive" = _t, #"BP GoLive" = _t, Other = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Epic GoLive", type date}, {"BP GoLive", type date}, {"Other", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Min(Record.ToList(_)), type date)
in
    #"Added Custom"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Alexis Olson