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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Min/Max Date from an other table, based on multiple conditions

Hi

 

I'm trying to enrich a customer table based on their orders.

 

I have a table with the customers and I would like to add their first orders date for different stores

 

Table 1 : Orders

OrderContactStoreDate
A11A01/01/2022
B21B02/01/2022
B31B10/01/2022
A22A04/01/2022
B13B05/01/2022
B43B20/01/2022

 

Table 2 : Customers (with the info I'd like to get from orders)

ContactMin_Date_AMin_Date_B
101/01/202202/01/2022
204/01/2022 
3 05/01/2022

 

 

I don't know how to start created my formula, and don't even know if I should do it on PowerQuery or in the Data View tab.

 

Anyone could help?

 

Thanks

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

pls try this

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VczRCQAhDAPQXfIt0kZvgLpGcf81tHBCC8nXI3GHKRqidivabygkdnMs/rbCWG0kUylmseP7nHUXm/E+v2ozGdPnPg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Order = _t, Contact = _t, Store = _t, Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Order", type text}, {"Contact", Int64.Type}, {"Store", type text}, {"Date", type date}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Order"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Store]), "Store", "Date", List.Min)
in
    #"Pivoted Column"

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thanks

It works perfectly

Ahmedx
Super User
Super User

pls try this

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VczRCQAhDAPQXfIt0kZvgLpGcf81tHBCC8nXI3GHKRqidivabygkdnMs/rbCWG0kUylmseP7nHUXm/E+v2ozGdPnPg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Order = _t, Contact = _t, Store = _t, Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Order", type text}, {"Contact", Int64.Type}, {"Store", type text}, {"Date", type date}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Order"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Store]), "Store", "Date", List.Min)
in
    #"Pivoted Column"

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors