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! Request now

Reply
Anonymous
Not applicable

Previous day need to find based on dates

Hi,

 

I have an entries with missing dates, need to find previous day value based on data below.

 

Current formula is taking as sequiance days like 1st, 2nd, 3rd etc: 

PreviousDay = CALCULATE(SUM('ZWD_RECON_SUM TableA'[Value]),
PREVIOUSDAY('Date_calender'[Date]))

Below data & excepted output in previous day column.

charanoffbit_0-1639676926824.png

 

Thanks

Charan

 

1 ACCEPTED SOLUTION
themistoklis
Community Champion
Community Champion

@Anonymous 

 

I have created 2 calculated columns.

Thie first holds the ranking of the rows and the second calculates the previous value.

 

I have also attached the PowerBI workspace on this message.

 

Ranking = 
RANKX( 
    ALL( Sheet1 ), 
    Sheet1[Start Date],, 
    ASC, 
    Dense 
) 

 

Previous Value = 
VAR _CurrentRowIndex = Sheet1[Ranking]                  
VAR _PreviousRowIndex = CALCULATE(
    MAX(Sheet1[Ranking] ),                                   
    FILTER( Sheet1, Sheet1[Ranking] < _CurrentRowIndex ), 
    ALL( Sheet1[Ranking] )                                   
) 
VAR _Result = CALCULATE(
    MAX( Sheet1[This Day] ),                          
    FILTER( Sheet1, Sheet1[Ranking] = _PreviousRowIndex ) 
) 

RETURN
    _Result

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi, Thanks for the response, the logic which you provided is not working on my actual data and posted raw data and exepted output here. 

charanoffbit_0-1639763658358.png

Thanks

Charan

themistoklis
Community Champion
Community Champion

@Anonymous 

 

I have created 2 calculated columns.

Thie first holds the ranking of the rows and the second calculates the previous value.

 

I have also attached the PowerBI workspace on this message.

 

Ranking = 
RANKX( 
    ALL( Sheet1 ), 
    Sheet1[Start Date],, 
    ASC, 
    Dense 
) 

 

Previous Value = 
VAR _CurrentRowIndex = Sheet1[Ranking]                  
VAR _PreviousRowIndex = CALCULATE(
    MAX(Sheet1[Ranking] ),                                   
    FILTER( Sheet1, Sheet1[Ranking] < _CurrentRowIndex ), 
    ALL( Sheet1[Ranking] )                                   
) 
VAR _Result = CALCULATE(
    MAX( Sheet1[This Day] ),                          
    FILTER( Sheet1, Sheet1[Ranking] = _PreviousRowIndex ) 
) 

RETURN
    _Result

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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!

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