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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Ttaylor9870
Helper III
Helper III

Amount of sales in tbl_A after the delivery date of a product from tbl_B

Hey All!

 

I'm stuck with the following problem. I'm trying to see what the Sales for customers are in tbl_A before & after the customer recieved a promo product. 🙂

tbl_A contains the order_received_date & customer_id.

tbl_B contains the promo_sent_date & customer_id.

 

2 fact tables (tbl_A & tbl_B) linked by date & customer dimension tables. (Star Schema).

 

Many Thanks,

 

Taylor

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Ttaylor9870 ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data. 

vtangjiemsft_0-1703147822504.png

vtangjiemsft_1-1703147831735.png

(2) We can create a calculated column.

Column = 
var _date=CALCULATE(MAX('tbl_B'[promo_sent_date]),FILTER('tbl_B',[customer_id] = EARLIER('tbl_A'[customer_id])))
var _sales=CALCULATE(MAX('tbl_B'[sales]),FILTER('tbl_B',[customer_id] = EARLIER('tbl_A'[customer_id])))
RETURN IF([order_received_date]>=_date,_sales,[sales])

(3) Then the result is as follows.

vtangjiemsft_2-1703147873631.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

2 REPLIES 2
Anonymous
Not applicable

Hi @Ttaylor9870 ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data. 

vtangjiemsft_0-1703147822504.png

vtangjiemsft_1-1703147831735.png

(2) We can create a calculated column.

Column = 
var _date=CALCULATE(MAX('tbl_B'[promo_sent_date]),FILTER('tbl_B',[customer_id] = EARLIER('tbl_A'[customer_id])))
var _sales=CALCULATE(MAX('tbl_B'[sales]),FILTER('tbl_B',[customer_id] = EARLIER('tbl_A'[customer_id])))
RETURN IF([order_received_date]>=_date,_sales,[sales])

(3) Then the result is as follows.

vtangjiemsft_2-1703147873631.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Tom_Y
Advocate II
Advocate II

Combine that 2 tables, so the new table will have the following columns:

Client ID/ Sales Date/ Sales amount/ Promotion date

Add a Custom column, and some simple code like (if Sales Date > promotion date, then AFTER, else then BEFORE). I'm not good at coding, hope you understand what I mean.

And then you can use the Maxtrix Visual to sort out BEFORE/ AFTER easily.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.