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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Syndicate_Admin
Administrator
Administrator

Add according to condition

Dear friends, I need your help to solve a problem that has arisen and I can't find a way to solve it

I have 2 tables which are related from 1 (VW_EvaProData2(2) to many (VW_EvaProRec). In the first table I have a list that corresponds to the purchase orders executed with all the information related to them, and in the second table I have the information to the receipts of the products associated with the purchase orders.

RodriCP_0-1697467252812.png

What I need to do is to be able to make a column which indicates the sum of what I received before a certain date

NumOCFechaOCFecha_CompstateCodAuxObsOCTotal$
10263007/01/202214/01/2022Approved9205200060STOCK5415028

CodProdFecha_ROrderCantIngresadaocCorrelaPreUniMBValor_recepFech_compState
H2510185113/01/202210263041138295531614/01/2022Delayed
H4510010013/01/202210263010234313431014/01/2022Delayed
K2010190013/01/2022102630100329828298280014/01/2022Delayed
K2015030013/01/20221026301041931219312014/01/2022Delayed
R4510030009/02/20221026301005648764870014/01/2022In PLazo
R4510030325/01/2022102630736428431273214/01/2022In PLazo
R4510030309/02/2022102630276428411566814/01/2022In PLazo
R4510040025/01/2022102630567842747191214/01/2022In PLazo
R4510040013/01/2022102630247842720224814/01/2022Delayed
R4510050025/01/20221026301081207612076014/01/2022In PLazo
G1810020013/01/20221026301009162816280014/01/2022Delayed
G1810022309/02/20221026305010229711485014/01/2022In PLazo


The idea is to be able to add a column in the first table (Summary Table) that tells me the sum of the value column Valor_recep, when the date field is Fecha_R less than or equal to Fecha_Comp. In the example, it should look like

RodriCP_1-1697468303728.png

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

Hi @Syndicate_Admin ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

vtangjiemsft_0-1697595513361.png

(2) We can create a calculated column.

Column = CALCULATE(SUM('Table (2)'[Valor_recep]),FILTER('Table (2)','Table (2)'[Order]=EARLIER('Table'[NumOC]) && 'Table (2)'[Fecha_R] <='Table (2)'[Fech_comp]))

(3) Then the result is as follows.

vtangjiemsft_1-1697595554717.png

Best Regards,

Neeko Tang

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

1 REPLY 1
v-tangjie-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

vtangjiemsft_0-1697595513361.png

(2) We can create a calculated column.

Column = CALCULATE(SUM('Table (2)'[Valor_recep]),FILTER('Table (2)','Table (2)'[Order]=EARLIER('Table'[NumOC]) && 'Table (2)'[Fecha_R] <='Table (2)'[Fech_comp]))

(3) Then the result is as follows.

vtangjiemsft_1-1697595554717.png

Best Regards,

Neeko Tang

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

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.