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
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
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.

Top Solution Authors