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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Morten_DK
Helper I
Helper I

Calculate inventory days, but only when there is inventory QTY

I am trying to calculate inventory days (meaning how long time will the item theoretically be on stock from now on, based on history) with this measure:

 

Inventory Days2 =
calculate(
    DIVIDE([Inventory Valuation]*90,[Outflow Value 3M]),
    [Inventory QTY]<>0
            )
But then I get this error:
Morten_DK_0-1679578693375.png

 

Inventory QTY is a measure in itself:

Inventory QTY =
CALCULATE (
    SUM ( 'Value Entries'[Item Ledger Entry Quantity] ),
    'Value Entries'[Item Ledger Entry Type] < 7,
    CALCULATETABLE (
        FILTER ( ALL ( 'Date' ), 'Date'[Date] <= MAX ( 'Date'[Date] ) )
    )
)
 
I have tried with "if" and "sumx", but they don't seem to get the grand total right.
 
Right now I get this result:
ItemInventory valuationOutflow Value 3MInventory QTYInventory days
A100150360
B2001504120
C 15000
Total300450760

 

But the issue there is, that for Item "C" the outflow value of 150 does not have any influence really on the row for item "C", but on the total the 150 is included, for calculation purpose this would be the right result regarding inventory days:

ItemInventory valuationOutflow Value 3MInventory QTYInventory days
A100150360
B2001504120
     
Total300300790

 

4 REPLIES 4
Anand24
Super User
Super User

Hi @Morten_DK ,
Can you put some sample data here with expected result and current result?

PBI_SuperUser_Rank@1x.png  

Give a Thumbs Up if this post helped you in any way and Mark This Post as Solution if it solved your query !!!

Proud To Be a Super User !!!
LinkedIn

I have updated the original post with some sample data, hope that helps 🙂

@Morten_DK ,
Here's your solution DAX:

Inventory Days2 = 
DIVIDE(
    CALCULATE(
        SUM('Table (3)'[Inventory valuation]),
        'Table (3)'[Inventory valuation] <> BLANK()
    )*90,
    CALCULATE(
        SUM('Table (3)'[Outflow Value 3M]),
        'Table (3)'[Inventory valuation] <> BLANK()
    )
)

Please make other changes accordingly because I have created the DAX according to the data your provided.

Result:

Anand24_0-1679586129542.png

 

PBI_SuperUser_Rank@1x.png  

Give a Thumbs Up if this post helped you in any way and Mark This Post as Solution if it solved your query !!!

Proud To Be a Super User !!!
LinkedIn

Thanks for the feedback. I can't get the proposed solution working, as "Inventory valuation" is also a measure

 

Inventory Valuation =
CALCULATE (
    [Total GL INV],
    'Value Entries'[Item Ledger Entry Type] < 7,
    CALCULATETABLE (
        FILTER ( ALL ( 'Date' ), 'Date'[Date] <= MAX ( 'Date'[Date] ) )
    )
)
 
My data is that I have the general ledger entries, where I need to sum up all transactions until given date, but that also means that I can get a sum of the transactions equal to zero. That can for instance happen if I had stock value in march 2022 and then consumption of all stock in april 2022, so looking at the data in december 2022 then the sum would be zero. 

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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

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