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
KyawMyoTun
Helper IV
Helper IV

Combine daily amount only based on Date

Dear Experts,
 I have two different tables called Sale and Cost.
But these two tables' data are from different system.
There are no unique ID columns except date.
So, I'd like to combine cost's amount to sale table.
I tried to connect by date table but there are multiple columns in both sale and cost tables.
How can I get correct sale and cost amount by filtering Date table.
My meain purpose is to calculate Margin (Sale - Cost) based on date.
The data are as below
Sale Table

DateCustomer NameAmount
1/1/2024AAA co.,ltd200
1/1/2024BBB Inc100
1/2/2024ABC Ltd500
1/3/2024JD200
1/3/2024Idea Inc400
1/3/2024Jasmine Ltd700


Cost Table

DateSupplier NameAmount
1/1/2024Super Trading300
1/2/2024ARC Mart500
1/3/2024TcT Ltd600
1/3/2024BNT Co.700



Thanks and Regards,
KMT

1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Hi @KyawMyoTun -  create a new Date table that includes all dates covering the range in both your Sale and Cost tables.

rajendraongole1_0-1731574823096.png

 

Create a relationship between the Date column in the Date Table and the Date column in both the Sale and Cost tables.

 

rajendraongole1_1-1731574863003.png

 

 

Instead of combining the tables directly, you can create measures that calculate the total sale and cost amounts per date using the relationships you set up.

 

Total Cost Amount = SUM(CostT[Amount])
 
Total Sales Amount = SUM(SaleST[Amount])
 
Final output:
rajendraongole1_2-1731574919379.png

 

Hope this helps





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

3 REPLIES 3
Kedar_Pande
Super User
Super User

@KyawMyoTun 

Create a Date Table:

DateTable = 
ADDCOLUMNS(
CALENDAR(MIN(Sale[Date]), MAX(Cost[Date])),
"Year", YEAR([Date]),
"Month", MONTH([Date]),
"Day", DAY([Date])
)

Now, create relationships between the Date table and the Sale and Cost tables.

 

Total Sales Measure

Total Sales = SUM(Sale[Amount])

Total Cost Measure

Total Cost = SUM(Cost[Amount])

Margin Measure

Margin = [Total Sales] - [Total Cost]

 

Add a table or matrix visual to your Power BI report.
Add the Date from the Date table to the visual to see data by date.
Add the Total Sales, Total Cost, and Margin measures to the table.

 

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

rajendraongole1
Super User
Super User

Hi @KyawMyoTun -  create a new Date table that includes all dates covering the range in both your Sale and Cost tables.

rajendraongole1_0-1731574823096.png

 

Create a relationship between the Date column in the Date Table and the Date column in both the Sale and Cost tables.

 

rajendraongole1_1-1731574863003.png

 

 

Instead of combining the tables directly, you can create measures that calculate the total sale and cost amounts per date using the relationships you set up.

 

Total Cost Amount = SUM(CostT[Amount])
 
Total Sales Amount = SUM(SaleST[Amount])
 
Final output:
rajendraongole1_2-1731574919379.png

 

Hope this helps





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Dear @rajendraongole1 ,
 This is working properly. 
Actually I have tried the same but not working before.
I am not sure why happened like that.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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