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
rcb0325
Helper I
Helper I

Trying to create a new column to track inventory levels

Hello! I am trying to create a new column in the "fact inventorytransactions" table that will show the current inventory level, and calculate the past inventory levels based on transactions. 

 

In the table below, I have the 'dim Date'[ActualDate], the 'fact InventoryTransactions'[Quantity], the 'fact InventorySummary'[OnhandQty], and the new column 'fact InventoryTransactions[InventoryLevel]

 

My thought is that by adding the current OnHandQty to the Quantity, I can create a column with the OnHandQty by date. The OnHandQty is not a hard coded value, but is updated daily with the current inventory value. 

 

Ex:

11/13/2024: InventLevel = 151 

11/12/2024: Invent Level = 151 + 37

11/11/2024: Invent Level = 151 + 37 + 152

 

Below is a snapshot of the table, and then how those columns are related. There are no calculated measures, other than the "InventoryLevel" column, which is what I am trying to calculate. All values are exported from D365. 

 

There is a relative date filter on the page that filters to 'dim Date'[ActualDate] is within the last 12 months (not including today) (11/19/2023 - 11/18/2024) 

 

rcb0325_0-1731945616112.png

 

rcb0325_1-1731945866776.png

 

Thanks in advance!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @rcb0325 

 

Thank you very much Jai-Rathinavel for your prompt reply.

 

For your question, here is the method I provided:

 

Here's some dummy data

 

“dim Date”

vnuocmsft_0-1732088804629.png

 

“fact InventoryTransactions”

vnuocmsft_1-1732088861367.png

 

“fact InventorySummary”

vnuocmsft_2-1732088900117.png

 

Create measures.

 

First, get the absolute value of the [Quantity] column.

 

ABS Quantity = ABS(SELECTEDVALUE('fact InventoryTransactions'[Quantity]))

 

Then,

 

InventoryLevel = 
VAR CurrentDate = SELECTEDVALUE('dim Date'[ActualDate])
VAR maxDate = CALCULATE(MAX('dim Date'[ActualDate]), ALL('dim Date'))
VAR CurrentOnHandQty = 
    CALCULATE(
        MAX('fact InventorySummary'[OnhandQty]),
        FILTER(
            ALL('fact InventorySummary'),
            'fact InventorySummary'[Date] = maxDate
        )
    )
VAR PreviousTransactions = 
    SUMX(
        FILTER(
            'fact InventoryTransactions',
            'fact InventoryTransactions'[TransactionDate] > CurrentDate
        ),
        'Measure'[ABS Quantity]
    )
RETURN
IF(
    SELECTEDVALUE('fact InventoryTransactions'[TransactionDate]) = maxDate,
    CurrentOnHandQty,
    CurrentOnHandQty + PreviousTransactions
)

 

Here is the result.

 

vnuocmsft_4-1732089267523.png

 

Regards,

Nono Chen

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
Anonymous
Not applicable

Hi @rcb0325 

 

Thank you very much Jai-Rathinavel for your prompt reply.

 

For your question, here is the method I provided:

 

Here's some dummy data

 

“dim Date”

vnuocmsft_0-1732088804629.png

 

“fact InventoryTransactions”

vnuocmsft_1-1732088861367.png

 

“fact InventorySummary”

vnuocmsft_2-1732088900117.png

 

Create measures.

 

First, get the absolute value of the [Quantity] column.

 

ABS Quantity = ABS(SELECTEDVALUE('fact InventoryTransactions'[Quantity]))

 

Then,

 

InventoryLevel = 
VAR CurrentDate = SELECTEDVALUE('dim Date'[ActualDate])
VAR maxDate = CALCULATE(MAX('dim Date'[ActualDate]), ALL('dim Date'))
VAR CurrentOnHandQty = 
    CALCULATE(
        MAX('fact InventorySummary'[OnhandQty]),
        FILTER(
            ALL('fact InventorySummary'),
            'fact InventorySummary'[Date] = maxDate
        )
    )
VAR PreviousTransactions = 
    SUMX(
        FILTER(
            'fact InventoryTransactions',
            'fact InventoryTransactions'[TransactionDate] > CurrentDate
        ),
        'Measure'[ABS Quantity]
    )
RETURN
IF(
    SELECTEDVALUE('fact InventoryTransactions'[TransactionDate]) = maxDate,
    CurrentOnHandQty,
    CurrentOnHandQty + PreviousTransactions
)

 

Here is the result.

 

vnuocmsft_4-1732089267523.png

 

Regards,

Nono Chen

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

Jai-Rathinavel
Super User
Super User

Hi @rcb0325 , Can you send the expected output, visualized in a excel table?




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

Proud to be a Super User!





Here is a copy of the excel table, that has the Inventory Level column calculated correctly. 
151 is the current inventory level (changes daily). I also believe it is the sum of ALL transactions for ALL dates.

Each previous day needs to subtract the transaction qty for the day following it. 

The Actual Date is only showing for days that there was an inventory transaction made

 

ActualDateSum of QuantitySum of OnHandQty (current day)Sum of InventoryLevel
11/13/2024-37151151
11/12/2024-152151188
11/7/20240151340
11/1/2024-5151340
10/25/2024-11151345
10/23/2024-161151356
10/22/2024-100151517
10/21/2024617151617
7/24/2024-21510
7/1/2024-291512
6/28/2024-3515131
6/27/2024-4515166
6/26/2024-50151111
6/20/2024-10151161
6/17/2024-35151171
6/13/2024-120151206
6/12/2024-18151326
6/10/2024-73151344
6/7/2024-268151417
6/6/2024-234151685
6/5/2024-100151919

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors