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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors