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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
leilei787
Helper II
Helper II

Look up first purchase date and adding total from two tables

Hi All, i have two questions, wonder if someone could help please!

 

i have two data tables. one contains orders that before year of 2020, another table contains orders that after 2020.

 

The table 1

 

Cust IDOrder DateProductQty
1001/1/2015A1
2002/4/2014C3
3005/10/2018A2
4006/4/2016C5
5007/3/2018A6
6004/6/2019A32
1002/4/2012BB5
2005/2/2011A3
3006/3/2018C6
4004/3/2019BB8
5009/3/2011A4
6006/5/2017A2

 

The table 2

Cust IDOrder DateProductQty
1004/2/2020A4
2005/3/2021BB2
3002/2/2022A5
4002/6/2020A6
5004/5/2020BB2
6008/1/2021BB2
7001/1/2021A1
8003/1/2022A4

 

i want to do the following

 

1) look up the first purchase data across two tables. for example, for product A, cust ID 100 first purchase date was 1/1/2015; for Cust ID 700, the first purchase date was 1/1/2021...for product BB, Cust ID 200 First purchase date was 5/3/2021.....basically to check two table and find the first purchase date

 

2) sum up total unit of product from two tables...for example, total units of product A that customer ID 100 purchased = 5 (1 from table A and 4 from table B)

 

thank you all!!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @leilei787 ,

 

Create a calculated table.

Table3 = UNION(Table1,Table2)
Then create measures.
_first = CALCULATE(MIN(Table3[Order Date]),ALLEXCEPT(Table3,Table3[Cust ID],Table3[Product]))
_sum = CALCULATE(SUM(Table3[Qty]),ALLEXCEPT(Table3,Table3[Cust ID],Table3[Product]))
1.jpg
 
Best Regards,
Jay

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @leilei787 ,

 

Create a calculated table.

Table3 = UNION(Table1,Table2)
Then create measures.
_first = CALCULATE(MIN(Table3[Order Date]),ALLEXCEPT(Table3,Table3[Cust ID],Table3[Product]))
_sum = CALCULATE(SUM(Table3[Qty]),ALLEXCEPT(Table3,Table3[Cust ID],Table3[Product]))
1.jpg
 
Best Regards,
Jay
amitchandak
Super User
Super User

@leilei787 , One you you append these two table in power Query

 

Append : https://radacad.com/append-vs-merge-in-power-bi-and-power-query

 

The second is create common dimensions for Date, product, Customer ID and join with both table

 

Create a combine measure and analyze using common tables

Sum(Table1[Qty]) + Table2[Qty]

 

 

Bridge Table: https://www.youtube.com/watch?v=Bkf35Roman8&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=19

 


To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.