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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Sum values of different months

Greetings guys,

 

I have two tables that I am using as a database.

 

Table 1

MonthScore1
210
320
430
540
650

 

Table2

MonthScore2
3100
4100
5100
6100
7100

 

I created 2 measures using SUM to get the Score value, but when I do SumScore1 + SumScore2, it sums the values of the same months. Nothing new so far.

 

But what I need is for the values in table 1 to be sum to the values in table 2, considering the following month.

 

MonthScore1Score2SUM
21000
320100110
430100120
540100130
650100140
70100150

 

How can I do this?

 

Best Regards,

1 ACCEPTED SOLUTION
v-yetao1-msft
Community Support
Community Support

Hi @Anonymous 

I think you can add a new Month table contains month from two tables. Then use LOOKUPVALUE dax to add another two columns from Table 1 and Table 2 .

Score1 = LOOKUPVALUE(Table1[Score1],Table1[Month],'Month'[Month])

Score2 = LOOKUPVALUE(Table2[Score2],Table2[Month],'Month'[Month])

Ailsa-msft_0-1617961543468.png

Then create a calculated column to sum score1 and score2

sum = CALCULATE(MAX('Month'[Score1]),FILTER('Month','Month'[Month]<EARLIER('Month'[Month])))+'Month'[Score2]+0

 

The effect is as shown:

Ailsa-msft_1-1617961543469.png

Best Regards

Community Support Team _ Ailsa Tao

 

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

3 REPLIES 3
v-yetao1-msft
Community Support
Community Support

Hi @Anonymous 

I think you can add a new Month table contains month from two tables. Then use LOOKUPVALUE dax to add another two columns from Table 1 and Table 2 .

Score1 = LOOKUPVALUE(Table1[Score1],Table1[Month],'Month'[Month])

Score2 = LOOKUPVALUE(Table2[Score2],Table2[Month],'Month'[Month])

Ailsa-msft_0-1617961543468.png

Then create a calculated column to sum score1 and score2

sum = CALCULATE(MAX('Month'[Score1]),FILTER('Month','Month'[Month]<EARLIER('Month'[Month])))+'Month'[Score2]+0

 

The effect is as shown:

Ailsa-msft_1-1617961543469.png

Best Regards

Community Support Team _ Ailsa Tao

 

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

Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please check the sample pbix file's link down below if that is what you are looking for.

 

Picture3.png

 

Sums =
VAR currentmonth =
MAX ( Months[Month] )
RETURN
SUM ( Table2[Score2] )
+ CALCULATE ( SUM ( Table1[Score1] ), Months[Month] = currentmonth - 1 )

 

https://www.dropbox.com/s/4jltqdi0usdj4lc/gdalpai%202021%200407.pbix?dl=0 

 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


amitchandak
Super User
Super User

@Anonymous , You need to create a common month table and join both tables with that and then analyze data using the month in the new table

Video: https://www.youtube.com/watch?v=Bkf35Roman8

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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