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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
lawada4
Frequent Visitor

how to get the value for the previous non blank date

im trying to find previuos day price for stocks so that i can calculate Day on Day change. the problem is stock market is not open everyday and in this case some days will be blank when i calculate previous day price  . im using the following measure to get previous day stock price:

previous day price = CALCULATE(SUM('stocks data'[Close]), PREVIOUSDAY('stocks data'[Date]))
this is a screenshot of the measure results:
lawada4_0-1671110283338.png

expected result:

lawada4_0-1671111777731.png

 

any idea on how to fix the measure to calculate previous stock price based on the last non blank date 

4 REPLIES 4
Mahesh0016
Super User
Super User

Please share exepacted result snap shot for understanding.

lawada4_0-1671111743833.png

 

previous day price = CALCULATE(SUM('Stock'[Close Price]), OFFSET(-1,ALLSELECTED(Stock[Date]),ORDERBY(Stock[Date],ASC)))

@lawada4  Please try this.

If no work so can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data and OFFSET In -1 Or +1 set your conditions.

the measure works only  in a table visual with the date field added in the table

lawada4_0-1671256356171.png

however the measure is in card visual it doesnt give me value for the previous nonblank day but the sum of all values in the selected date period. 

lawada4_1-1671256677515.png

previous day price measure should return 142.16 which is the closing price for the previous non blank date

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.