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

Cumulative Total Based on Plant, Material, and Date

Hi All,

 

Iam stuck with some calculation of arriving cumulative total.

The following is the data i have.

Plant IdMaterialReq/Availbility Date Opening Qty  Qty Utilized 
111040026931-05-2022          10,375             219
111040026924-06-2022          10,375            -576
111040026924-06-2022          10,375            -856
111040026924-06-2022          10,375            -960
111040026901-07-2022          10,375            -128
111040026901-07-2022          10,375         -1,024
111140026931-05-2022          50,000               -8
111140026924-06-2022          50,000         -4,000
111140026924-06-2022          50,000          1,000
111140026924-06-2022          50,000            -340
111140026901-07-2022          50,000         -4,577
111140026901-07-2022          50,000             434

I need to calculate the cumulative (measure or column) based on the Plant, Material, and Date.

For example for Plant 1110 and material 40269 the least date is 31-05-2022 and opening inventory is 10,375 and utilized is 219. So for this line my cumulative is 10375 + 219 = 10594.

Next cumulative should be 10594 + (-596) = 10,018 and so on.

When the next combination ofh Plant and MAterial starts i.e., Plant 1111 and material 4000269 againfirst calucaltin should be of the least date 31-05-2022 and cumulative total is 50000 + (-8) = 49992 and second calcualation is 49992 + (-4000) = 45992.

 

The following is the sample result for your reference.

Plant IdMaterialReq/Availbility Date Opening Qty  Qty Utilized Cumulative
111040026931-05-2022          10,375             219     10,594
111040026924-06-2022          10,375            -576     10,018
111040026924-06-2022          10,375            -856       9,162
111040026924-06-2022          10,375            -960       8,202
111040026901-07-2022          10,375            -128       8,074
111040026901-07-2022          10,375         -1,024       7,050
111140026931-05-2022          50,000               -8     49,992
111140026924-06-2022          50,000         -4,000     45,992
111140026924-06-2022          50,000          1,000     46,992
111140026924-06-2022          50,000            -340     46,652
111140026901-07-2022          50,000         -4,577     42,075
111140026901-07-2022          50,000             434     42,509

Please suggest me a way to create either measure or column.

 

@amitchandak  @Ashish_Mathur @ChandeepChhabra @Fowmy  @JihwanKim @Jihwan_Kim 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Assuming Opening Qty is in every row

 

a new column =

[Opening Qty] + sumx(filter(Table, [Plant] = earlier([Plant])  && [Material] = Earlier([Material]) && [Availbility  Date] <= earlier([Availbility  Date]) ),[Qty Utilized])

 

a new measure

 

 

Max(Table[Opening Qty]) + sumx(filter(allselected(Table), [Plant] = max([Plant]) && [Material] = max([Material]) && [Availbility Date] <= max([Availbility Date]) ),[Qty Utilized])

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

@amitchandak Thanks this worked

 

SolomonovAnton
Responsive Resident
Responsive Resident

hello

 

first of all you should create Calendar table (_Calendar = Calendarauto())

create link between tables  '_Calendar'[date] and 'Table'[Req/Availbility Date]
after it create measure

 

TotalYTD = 
var _openQTY = min('Table'[ Opening Qty ])
var _YTD = TOTALYTD(SUM('Table'[ Qty Utilized ]),_Calendar[Date])
var _result = _openQTY+_YTD
return _result

 

then you can get result as bellow 

SolomonovAnton_1-1658822069362.png

 

If I answered at you question please mark topic as resolved 🙂

amitchandak
Super User
Super User

@Anonymous , Assuming Opening Qty is in every row

 

a new column =

[Opening Qty] + sumx(filter(Table, [Plant] = earlier([Plant])  && [Material] = Earlier([Material]) && [Availbility  Date] <= earlier([Availbility  Date]) ),[Qty Utilized])

 

a new measure

 

 

Max(Table[Opening Qty]) + sumx(filter(allselected(Table), [Plant] = max([Plant]) && [Material] = max([Material]) && [Availbility Date] <= max([Availbility Date]) ),[Qty Utilized])

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.