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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
ddpl
Solution Sage
Solution Sage

I want to get previous date count of stock...!!!

Hello Everyone,

 

Session DateCount of StockPrevious Day Count
The Result I Need
January 5, 2022...11 
January 10, 2022...1711
January 12, 2022...2617
January 17, 2022...2526
January 19, 2022...5225
January 24, 2022...9252
January 26, 2022...1292
January 31, 2022...4912
February 2, 2022...5349
February 7, 2022...5853
February 9, 2022...6458

 

Date is not daily occured, so basically amount should be nearest previous date's stock count.

 

Hope it make sence to you who are reading this.

 

Thanks in Advance.

2 ACCEPTED SOLUTIONS
tamerj1
Super User
Super User

Hi @ddpl 
I assume that Count of Stock is a measure not a summarized column, otherwise just create a simple count measure. You may then use

Previous Day Count =
VAR CurrentDate =
    SELECTEDVALUE ( TableName[Session Date] )
VAR PreviousRecords =
    FILTER ( ALL ( TableName ), TableName[Session Date] < CurrentDate )
VAR PreviousDate =
    MAXX ( PreviousRecords, TableName[Session Date] )
RETURN
    CALCULATE ( [Count of Stock], TableName[Session Date] = PreviousDate )

View solution in original post

@tamerj1 ,

 

It worked absolutely fine, Thanks.

 

 

@lukiz84 

 

Thanks for quick responce.

View solution in original post

3 REPLIES 3
tamerj1
Super User
Super User

Hi @ddpl 
I assume that Count of Stock is a measure not a summarized column, otherwise just create a simple count measure. You may then use

Previous Day Count =
VAR CurrentDate =
    SELECTEDVALUE ( TableName[Session Date] )
VAR PreviousRecords =
    FILTER ( ALL ( TableName ), TableName[Session Date] < CurrentDate )
VAR PreviousDate =
    MAXX ( PreviousRecords, TableName[Session Date] )
RETURN
    CALCULATE ( [Count of Stock], TableName[Session Date] = PreviousDate )

@tamerj1 ,

 

It worked absolutely fine, Thanks.

 

 

@lukiz84 

 

Thanks for quick responce.

lukiz84
Memorable Member
Memorable Member

Add a calculated column:

 

 

VAR maxDate = 
    CALCULATE(
        MAX(yourTable[Session Date]),
	FILTER(
		yourTable,
		yourTable[Session Date] < EARLIER(yourTable[Session Date])
        )
     )

RETURN
     CALCULATE(
	MAX(yourTable[Count of Stock]),
        yourTable[Session Date] = maxDate
     ) 

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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