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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Calculation in a row from another (next) row.

Hi Guys,
I could use some help with a DAX Formula!

See the table below:

ContractNumber PropertyNumber StartDate Enddate VacancyReason Fraud
Cr111-1-191-6-19nullYes
Cr212-6-194-6-19NoTenantNo
Cr315-6-1910-8-19nullYes
Cr4111-8-1922-9-19NoTenantNo
Cr5123-9-19nullnullNo
Cr623-1-196-6-19nullNo
Cr727-6-19nullNoTenantNo

In the table above there is an example of contracts per property (1 property can have multiple contracts). If a tenant has committed fraud, the contract will be terminated (see Cr1 or Cr3) and an end date will be added to the data. Till a new tenant has rented the property a temporary contract will be created (see Cr2). When a new tenant has rented a property a new contract will be created (see Cr3 or Cr5: end date is null because the tenant is still renting the property).

 

Like you see in Cr1 & Cr3, a property can have multiple fraud cases, so to calculate the vacancy days the dax formula should look to  the next vacancy contract of the property: 
the vacancy contract startdate > end date of the fraud contract and the vacancy contract enddate < start date of the new contract

How can I calculate the vacancy days of a property after the contract has been terminated because of fraud? So in this case:

ContractNumber PropertyNumber StartDate Enddate VacancyReason FraudVacancyDaysFraud
Cr111-1-191-6-19nullYes2
Cr212-6-194-6-19NoTenantNonull (or 2)
Cr315-6-1910-8-19nullYes42
Cr4111-8-1922-9-19NoTenantNonull (or 42)
Cr5123-9-19nullnullNonull
Cr623-1-196-6-19nullNonull
Cr727-6-19nullNoTenantNonull

 


Thanks

1 REPLY 1
lbendlin
Super User
Super User

1. generally you cannot calculate something from the "next" row. You can calculate something from the "previous"  row.  Change your sort order.

2. speaking of sort order - you need some sort of an index column that makes sorting unambiguous. Your contract start date might be an option.

 

It is still not clear to me what the actual expected outcome is.

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.