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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
seankeatingpb
New Member

DAX to lookup first product ordered based on Group ID

Good Day.

 

I am looking for a DAX formula that can display the first product ordered in a new column, based on the Group ID (expected results in Red😞

 

Group ID     Date/Time of order   Product     Expected Result   
34258215/11/2024 08:00CrispsCrisps
34258215/11/2024 08:01SweetsCrisps
34258215/11/2024 08:08Soft DrinkCrisps
34258215/11/2024 08:15TeabagsCrisps
34258315/11/2024 08:02TeabagsTeabags
34258315/11/2024 08:10SweetsTeabags
34258315/11/2024 08:11Soft DrinkTeabags
34258315/11/2024 08:07CrispsTeabags
34258415/11/2024 08:22CrispsSweets
34258415/11/2024 08:21SweetsSweets
34258415/11/2024 08:26Soft DrinkSweets
34258415/11/2024 08:35TeabagsSweets
34258515/11/2024 08:48CrispsSoft Drink
34258515/11/2024 08:45SweetsSoft Drink
34258515/11/2024 08:42Soft DrinkSoft Drink
34258515/11/2024 08:50TeabagsSoft Drink

 

 

Thanks in advance.

 

1 ACCEPTED SOLUTION
123abc
Community Champion
Community Champion

Try Belwo Measure:

 

First Product Ordered =
VAR FirstOrderTime =
CALCULATE(
MIN('Table'[Date/Time of order]),
ALLEXCEPT('Table', 'Table'[Group ID])
)
RETURN
CALCULATE(
FIRSTNONBLANK('Table'[Product], 1),
'Table'[Date/Time of order] = FirstOrderTime,
ALLEXCEPT('Table', 'Table'[Group ID])
)

 

Result in New Column:

Group ID Date/Time of order Product First Product Ordered

34258215/11/2024 08:00CrispsCrisps
34258215/11/2024 08:01SweetsCrisps
34258215/11/2024 08:08Soft DrinkCrisps
34258215/11/2024 08:15TeabagsCrisps
34258315/11/2024 08:02TeabagsTeabags
34258315/11/2024 08:10SweetsTeabags
34258315/11/2024 08:11Soft DrinkTeabags
34258315/11/2024 08:07CrispsTeabags
34258415/11/2024 08:22CrispsSweets
34258415/11/2024 08:21SweetsSweets
34258415/11/2024 08:26Soft DrinkSweets
34258415/11/2024 08:35TeabagsSweets
34258515/11/2024 08:48CrispsSoft Drink
34258515/11/2024 08:45SweetsSoft Drink
34258515/11/2024 08:42Soft DrinkSoft Drink
34258515/11/2024 08:50TeabagsSoft Drink

This will display the expected results as per your requirements. Let me know if you need further clarification!

View solution in original post

3 REPLIES 3
seankeatingpb
New Member

Thanks for your help, that has done the trick!

U r always  welocme

123abc
Community Champion
Community Champion

Try Belwo Measure:

 

First Product Ordered =
VAR FirstOrderTime =
CALCULATE(
MIN('Table'[Date/Time of order]),
ALLEXCEPT('Table', 'Table'[Group ID])
)
RETURN
CALCULATE(
FIRSTNONBLANK('Table'[Product], 1),
'Table'[Date/Time of order] = FirstOrderTime,
ALLEXCEPT('Table', 'Table'[Group ID])
)

 

Result in New Column:

Group ID Date/Time of order Product First Product Ordered

34258215/11/2024 08:00CrispsCrisps
34258215/11/2024 08:01SweetsCrisps
34258215/11/2024 08:08Soft DrinkCrisps
34258215/11/2024 08:15TeabagsCrisps
34258315/11/2024 08:02TeabagsTeabags
34258315/11/2024 08:10SweetsTeabags
34258315/11/2024 08:11Soft DrinkTeabags
34258315/11/2024 08:07CrispsTeabags
34258415/11/2024 08:22CrispsSweets
34258415/11/2024 08:21SweetsSweets
34258415/11/2024 08:26Soft DrinkSweets
34258415/11/2024 08:35TeabagsSweets
34258515/11/2024 08:48CrispsSoft Drink
34258515/11/2024 08:45SweetsSoft Drink
34258515/11/2024 08:42Soft DrinkSoft Drink
34258515/11/2024 08:50TeabagsSoft Drink

This will display the expected results as per your requirements. Let me know if you need further clarification!

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.