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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

Latest Status

Hi All,

 

I want to show the current stock (inventory level)

 

I have two tables in import mode one a a stock (inventory table) and another a stock status table this status changes as the stock moves through the system. i.e goes from supplier order, to in stock, to invoiced, to archived. The stock key in the stock table is unique hower there are multiple entries for each status (description) in the stock status table

 

 

I just want to show the items that are in stock. I need a solution that works bearing in ming the status date is only a date column not tiPicture1.jpgme date so 2 statuses could take place on the same day. any help is much appreicated. 

1 ACCEPTED SOLUTION

Well, you could do this:

 

 

Status = 
VAR __maxDate = MAX('Stock Status Table'[Status Date])
VAR __stockKey = MAX('Stock Table'[Stock Key])
VAR __table = FILTER('Stock Status Table',[Stock Key]=__stockKey && [Status Date] = __maxDate)
VAR __count = COUNTX(__table,[Status Date])
RETURN
IF(__count >1 || ISBLANK(__count),"?",MAXX(__table,[Description]))

If you add an Index column to your Stock Status Table (with the assumption that your rows are sorted/ordered by Date from least recent to most recent), then you could do this:

 

 

Status2 = 
VAR __maxDate = MAX('Stock Status Table'[Status Date])
VAR __stockKey = MAX('Stock Table'[Stock Key])
VAR __table = FILTER('Stock Status Table',[Stock Key]=__stockKey && [Status Date] = __maxDate)
VAR __maxIndex = MAXX(__table,[Index])
VAR __table1 = FILTER(__table,[Index] = __maxIndex)
RETURN
MAXX(__table,[Description])

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @Greg_Deckler,

 

Could you please mark the proper answers as solutions?

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

How about a filter? Please refer to the snapshot below.

Latest-Status

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

Sample data would really help but basically you are going to use MAX of your date then you just have to figure out the multiple entries on a single day. Perhaps adding an Index to your query?

 

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi Greg,

 

Thanks for your reply please see attached sample data.Sample Data.PBIX

Well, you could do this:

 

 

Status = 
VAR __maxDate = MAX('Stock Status Table'[Status Date])
VAR __stockKey = MAX('Stock Table'[Stock Key])
VAR __table = FILTER('Stock Status Table',[Stock Key]=__stockKey && [Status Date] = __maxDate)
VAR __count = COUNTX(__table,[Status Date])
RETURN
IF(__count >1 || ISBLANK(__count),"?",MAXX(__table,[Description]))

If you add an Index column to your Stock Status Table (with the assumption that your rows are sorted/ordered by Date from least recent to most recent), then you could do this:

 

 

Status2 = 
VAR __maxDate = MAX('Stock Status Table'[Status Date])
VAR __stockKey = MAX('Stock Table'[Stock Key])
VAR __table = FILTER('Stock Status Table',[Stock Key]=__stockKey && [Status Date] = __maxDate)
VAR __maxIndex = MAXX(__table,[Index])
VAR __table1 = FILTER(__table,[Index] = __maxIndex)
RETURN
MAXX(__table,[Description])

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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