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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.