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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Subtract values of columns from two different tables based on date

Hi all!

 

I've been struggling with this issue and I haven't found a solution by myself. I hope I will find it here: I want to know if it is possible to get a measure of the difference of two values in different tables with the same date. 

 

As an example, these are my two tables:

 

Table A:

DateProductValue
25/03/2022A3.23
26/03/2022A3.39
25/03/2022B4.12
26/03/2022B4.29

 

Table B:

 

DateProductValue
25/03/2022A13.02
26/03/2022A13.12
25/03/2022B14.19
26/03/2022B14.32

 

What I'd like to get is a calculated measure of the difference of value of product A in Table A minus the value of product A1 in Table B for each date, and finally draw a line chart with this calculated measure that shows the evolution of this difference. I'd like to avoid a solution involving joining these two tables through the date

 

Thus, for products A and A1, the values would be the following: 

 

On March 25th, 3.23 (which is the value of Product A) - 3.02 (which is the value of Product B)=0.21

On March 26th, 3.39 (which is the value of Product A) - 3.12 (which is the value of Product B)=0.27

 

Thanks in advance for your kind help 🙂

 

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

You can create a bridge table to connect tableA and tableB with the following formula, but you can customize the specific calculation logic for the two tables (correlation of the product fields).

Cal =
DISTINCT ( UNION ( ALL ( TableA[Date] ), ALL ( TableB[Date] ) ) )

vhenrykmstf_0-1648545797685.png

vhenrykmstf_1-1648545814496.png


If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


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
v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

You can create a bridge table to connect tableA and tableB with the following formula, but you can customize the specific calculation logic for the two tables (correlation of the product fields).

Cal =
DISTINCT ( UNION ( ALL ( TableA[Date] ), ALL ( TableB[Date] ) ) )

vhenrykmstf_0-1648545797685.png

vhenrykmstf_1-1648545814496.png


If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


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

amitchandak
Super User
Super User

@Anonymous , You have create a common date and product table and join with both tables. Then you can take diff in visual on a common date and product dimensions

 

sum(Table1[Value]) - Sum(Table2[Value])

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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