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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
lawada4
Frequent Visitor

how to create a measure to return value for previous nonblank date

im trying to create a measure that returns the closing price for the previous day for a stock. however in some days the stock market is closed so the previous date in this case will be blank. 

i used the following measure to get the value for last non blank date but its only working in table visual when the date field is added

previous day price1 = CALCULATE(SUM('stocks data'[Close]), OFFSET(-1,ALLSELECTED('stocks data'[Date]),ORDERBY('stocks data'[Date],ASC)))

lawada4_0-1671258014387.png

when i added the measure to card visual it's returing the sum value of the previous closing price instead of the previous day.

lawada4_1-1671258133614.png

 

in the selected date period , the previous nonblank date is 12-9-2022 and the measure should return142.16 and the day on day change value should be 1.61%

lawada4_2-1671258303495.png

 

 

any idea on how to fix the measure?

4 REPLIES 4
Mahesh0016
Super User
Super User

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

im looking to have the output in a card visual not in a table format per row.  the result should be 142.16 instead of the sum of all values which is 131062.04

lawada4_0-1671261801688.png

 

Mahesh0016
Super User
Super User

previous day price1 = CALCULATE(

SELECTEDVALUE('stocks data'[Close])

OFFSET(-1,ALLSELECTED('stocks data'[Date]),ORDERBY('stocks data'[Date],ASC)))

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!

i have used same measure as i mentioned up but it's not returning correct value in card visual so still didnt solve my problem. any idea on how to modify the measure to get the intended output?

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.