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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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