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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
JamesGordon
Helper II
Helper II

Inventory Trend Analysis

Hi all,

I’m sure there is a simple way to achieve this but I am struggling to achieve what I am after. I am trying to create bar chart that shows the amount of stock on hand today and historically. I’m trying to analyse stock trends such as current stock level vs historical stock levels.

https://jamesgordon-my.sharepoint.com/:x:/g/personal/james_moss_jgordon_co_uk/EXVDaTiYG2ROoNk4gec8Fi... 

In my data (Sample file link above) I have:

  • Rcv date – Date Received in stock
  • Inv date – Date Sold out of stock
  • If Inv date if blank means still in stock
  • Price

 

There are some other columns but the above should provide all detail required.

I also have a separate date table/calendar.

 

What Measures or Calculated columns would I required to display a bar graph by date as per below (the graph is wrong but gives an idea what im looking to achieve)?

 

Any help would be appreaicted

inventory.jpg

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

The basic formula is

Stock Level = 
var maxDate = MAX('Date'[Date])
var minDate = MIN('Date'[Date])
return CALCULATE( [Base Measure], 'Table'[Rcv Date] >= minDate && 'Table'[Rcv Date] <= maxDate &&
( 'Table'[Inv Date] > maxDate || ISBLANK('Table'[Inv Date] )
)

You don't need any relationships between your date table and data table for this to work.

View solution in original post

3 REPLIES 3
johnt75
Super User
Super User

It sounds like there may be a filter being based from the Date table. Is there a relationship between the Date table and the data table? If there is you could add REMOVEFILTERS('Date') to the CALCULATE statement.

johnt75
Super User
Super User

The basic formula is

Stock Level = 
var maxDate = MAX('Date'[Date])
var minDate = MIN('Date'[Date])
return CALCULATE( [Base Measure], 'Table'[Rcv Date] >= minDate && 'Table'[Rcv Date] <= maxDate &&
( 'Table'[Inv Date] > maxDate || ISBLANK('Table'[Inv Date] )
)

You don't need any relationships between your date table and data table for this to work.

@johnt75 

Thank you for your help. I have tried your formula and it appears to be getting close. Something isnt quite working through. 

If i put the results into a table i get the figure i would expect 10,980,463.41 for todays stock level - however when i try to put into a bar graph the 2022 stock level is only showing 4,302,876.35

I cannot see why this would be the case? as per below?

Workings.jpg

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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