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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
dgranddemars
Frequent Visitor

Calculated column with sum and filters

Hello

 

I don't manage to define the formula to crete the following calculated column : 

 I have 3 tables

Invoice

InvoiceNumAmountInvoice Date
12334

01/01/2023

12450

05/01/2023

 

Incomes

IncomeNumInvoiceNumAmountDate
00011232005/01/2023
00021231001/02/2023
00031244025/01/2023

 

 

Events

EventIDInvoiceNumDate
112330/01/2023
212401/02/2023

 

 

I try to add a column in the Events table to store the sum of incomes between the invoice date and the event date. I presume I need to use Calculate adn Filter function, but I don't manage to get something consistent.

 

Any help will be very appreciated

 

David

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @dgranddemars ,

 

Here are the steps you can follow:

1. Create calculated column.

Date_Invoice =
MAXX(
    FILTER(ALL(Invoice),
    'Invoice'[InvoiceNum]=EARLIER('Events'[InvoiceNum])),'Invoice'[Invoice Date])
Sum_Incomes =
SUMX(
    FILTER(ALL(Incomes),
    'Incomes'[Date]>=EARLIER('Events'[Date_Invoice])&&'Incomes'[Date]<=EARLIER('Events'[Date])
    &&'Incomes'[InvoiceNum]=EARLIER('Events'[InvoiceNum])),[Amount])

2. Result:

vyangliumsft_0-1676596454913.png

 

Best Regards,

Liu Yang

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
dgranddemars
Frequent Visitor

Thanks for your help 🙂

Ashish_Mathur
Super User
Super User

Hi,

Show the expected result very clearly.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi  @dgranddemars ,

 

Here are the steps you can follow:

1. Create calculated column.

Date_Invoice =
MAXX(
    FILTER(ALL(Invoice),
    'Invoice'[InvoiceNum]=EARLIER('Events'[InvoiceNum])),'Invoice'[Invoice Date])
Sum_Incomes =
SUMX(
    FILTER(ALL(Incomes),
    'Incomes'[Date]>=EARLIER('Events'[Date_Invoice])&&'Incomes'[Date]<=EARLIER('Events'[Date])
    &&'Incomes'[InvoiceNum]=EARLIER('Events'[InvoiceNum])),[Amount])

2. Result:

vyangliumsft_0-1676596454913.png

 

Best Regards,

Liu Yang

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

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.