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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
RadoslawM
New Member

Subtracting rows

Hi folks,

 

I'm new here and quite new to power BI.

 

I have two tables:

1. Items with purchase date & Quantity

ItemNoPurchaseDateQuantityIndex
85420/03/2019322
85430/04/20194803
85407/05/2019164
85427/01/20192031
34620/05/201932
34623/07/201923
34622/01/201911
34608/08/201914

 

2. Sales forecast

ItemNoForecast
854350
3462

 

I would like to add Balance column to my table 1, that will subtract forecast from quantity, starting with the oldest PurchaseDate. My desired outcome is this:

ItemNoPurchaseDateQuantityIndexBalance
85420/03/20193220
85430/04/20194803365
85407/05/201916416
85427/01/201920310
34620/05/2019322
34623/07/2019232
34622/01/2019110
34608/08/2019141

How can I achieve this with simple measures?

 

Thanks in advance.

3 REPLIES 3
v-juanli-msft
Community Support
Community Support

Hi @RadoslawM 

My output is a bit different from yours.

Capture2.JPG

Create columns

clc_quan = CALCULATE(SUM('Table 1'[Quantity]),FILTER(ALLEXCEPT('Table 1','Table 1'[ItemNo]),'Table 1'[PurchaseDate]<=EARLIER('Table 1'[PurchaseDate])))

clc_quan = CALCULATE(SUM('Table 1'[Quantity]),FILTER(ALLEXCEPT('Table 1','Table 1'[ItemNo]),'Table 1'[PurchaseDate]<=EARLIER('Table 1'[PurchaseDate])))

Column = IF([clc_for]=BLANK(),0,[clc_quan]-[clc_for])

Please tell me if i misunderstand anything.

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ashish_Mathur
Super User
Super User

Hi,

How have you arrived at the numbers in the Balance column?  What is the logic?


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

SUM of Quantity minus Forecast = Balance is my logic, but it would only work if the table was grouped by item. 

 

 

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.