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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Arial36
Frequent Visitor

Formula to add pieces by date

Hello community! I need help:

 

I have a table that contains unique dates with different data.

 

Ex: Date - Hours - Resource, etc.

1/4/2021 - 20 - 2

2/4/2021 - 30 - 3

3/4/2021  ----

 

At the same time, I have another table that is related to this through the date, but the dates are repeated since for each day, per client, a count of processed units is made. Ex:

 

Date - Number of pieces, etc.

1/4/2021 - 1000

1/4/2021- 2500

1/4/2021 - 8000

etc.

 

What I would need to do is take the sum of those values ​​per day to the table first table. In the example, if for the 1/4 the sum is 11500, put that value in the first table that contains unique dates. With what DAX formula could I achieve it? I attach images to make it clearer. Thanks!

 

Ej 1.pngEj 2.png

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Arial36 

 

If your tables are related to each other on the Date column, you could use below code to add a new column to the first table. (First table: TableA, Second table: TableB)

Total value = CALCULATE(SUM(TableB[Value]))

061001.jpg

 

If no relationship exists on Date column, add a new column with code

Total value = CALCULATE(SUM(TableB[Value]),TableB[Date]=EARLIER(TableA[Date]))

 

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

View solution in original post

1 REPLY 1
v-jingzhang
Community Support
Community Support

Hi @Arial36 

 

If your tables are related to each other on the Date column, you could use below code to add a new column to the first table. (First table: TableA, Second table: TableB)

Total value = CALCULATE(SUM(TableB[Value]))

061001.jpg

 

If no relationship exists on Date column, add a new column with code

Total value = CALCULATE(SUM(TableB[Value]),TableB[Date]=EARLIER(TableA[Date]))

 

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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