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
AFra
Helper III
Helper III

Add column that summarizes a column from another table

Hi, 

 

I have two tables : 

A. 

SocietyTarget
A100
B200
C1000
D1200

 

B. 

DateSocietyAmount
29/02/2020A10
31/01/2020B12
29/02/2020C20
31/01/2020D10
29/02/2020A5
31/01/2020B10
29/02/2020C8
31/01/2020D12

 

I would like to add a new column on table A that summarizes the amounts (by society), but only for 29/02/2020. Thus, it would look like this : 

A. 

SocietyTargetAmount
A10015
B200 
C100028
D1200 

 

I took a few months off power bi and lost all my basics... 

Can someone help me with this? 

THanks in advance! 

 

ANa 

1 ACCEPTED SOLUTION
camargos88
Community Champion
Community Champion

Hi @AFra ,

 

You can try this code for calculated column:

 

CALCULATE(SUM('Table'[Amount]); FILTER(ALL('Table'); 'Table'[Society] = EARLIER('Table (2)'[Society]) && 'Table'[Date] = DATE(2020; 2; 29)))
 
If you need it for measures, it will change a little bit.
 
Ricardo


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
v-shex-msft
Community Support
Community Support

HI @AFra,

Did this date filter dynamic base on your filter/slicer? If this is a case, I'd like to suggest you write a measure formula to calculate. (current calculated column/table not able to interact with filter/slicer dynamically)

Measure =
CALCULATE (
    SUM ( TableB[Amount] ),
    FILTER ( ALLSELECTED ( TableB ), [Society] IN VALUES ( TableA[Society] ) ),
    VALUES ( TableB[Date] )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
camargos88
Community Champion
Community Champion

Hi @AFra ,

 

You can try this code for calculated column:

 

CALCULATE(SUM('Table'[Amount]); FILTER(ALL('Table'); 'Table'[Society] = EARLIER('Table (2)'[Society]) && 'Table'[Date] = DATE(2020; 2; 29)))
 
If you need it for measures, it will change a little bit.
 
Ricardo


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

Proud to be a Super User!



It works nicely, thanks a lot! 

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.