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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
omillzy
Helper III
Helper III

Creating a flattened timeline based on dates in multiple rows

I have a list of contracts for rental properties.

On each contract is a list of subscription lines detailing how much the customer will be paying across a certain timeframe - indicated by SBQQ__StartDate__c and SBQQ__EndDate__c. In the example below, the customer's contract starts on 26.08.2014 (paying full rent price) but is then offered 'Half Rent' from 26.08.2020 - 25.12.2020

After this period of half rent, the customer is returned back to full rent (SBQQ__ProductName__c = Office) - the problem is that we don't have a unique line/row for this entry. It's salesforce data so there must be some automation on the system which isn't replicated in the underlying dataset.

 

What I need to do is create a timeline of rental steps which I will then be index by contract & flatten into one line so I would have 1 contract number and all the flattened rental/contract steps (with the amount being payed by the customer at each step) pushed out into a very long wide dataset.

 

In my head this would be very easy to achieve, especially if I could utilise cell referencing, the logic is something like:
if datediff(SBQQ__EndDate__c[row 1], SBQQ_StartDate__c[row 2]) > 1 then insert a duplicate row of the full rent line (SBQQ_ProductName__c = Office) 

 

In simple english it's basically: "if there is a gap between the end date of the n rental step and start of n+1 rental step then return to full rent during this gap"

Here's the data for one contract and its rental steps. I've also attached a drawn picture to show how the concept is working in theory. I've got the code working to index by contract and flatten using SUMMARIZE() in DAX, I just need to insert a duplicate row each time there is a gap in the 'half rent' steps (or there may be a more elegant solution)

 

20200203_155044.jpg

 

Subscription LineNameSBQQ__ContractNumber__cSBQQ__ProductName__cSBQQ__StartDate__cSBQQ__EndDate__cTotal_Annualised_Rent__cTotal_Annual_Billable_Amount__c
SUB-000644200002588Office26/08/201425/08/2024568750
SUB-001704500002588Half Rent26/08/202025/12/2020null28437.49
SUB-001704600002588Half Rent26/08/202125/12/2021null28437.49
SUB-001704700002588Half Rent26/08/202225/12/2022null28437.49
SUB-001704800002588Half Rent26/08/202325/01/2024null28437.496
1 ACCEPTED SOLUTION
v-lid-msft
Community Support
Community Support

Hi @omillzy ,

 

Sorry for our late reply, We can create a measure used in line chart to meet your requirement:

 

Value = 
VAR T =
    FILTER (
        'Table',
        [SBQQ__StartDate__c] <= SELECTEDVALUE ( 'Calendar Table'[Date] )
            && [SBQQ__EndDate__c] >= SELECTEDVALUE ( 'Calendar Table'[Date] )
            && 'Table'[SBQQ__ProductName__c] = "Half Rent"
    )
RETURN
    IF (
        CALCULATE ( COUNTROWS ( 'Table' ), T ) > 0,
        CALCULATE ( SUM ( 'Table'[Total_Annual_Billable_Amount__c] ), T ),
        CALCULATE (
            SUM ( 'Table'[Total_Annualised_Rent__c] ),
            'Table'[SBQQ__ProductName__c] = "Office"
        )
    )

 

1.jpg


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-lid-msft
Community Support
Community Support

Hi @omillzy ,

 

Sorry for our late reply, We can create a measure used in line chart to meet your requirement:

 

Value = 
VAR T =
    FILTER (
        'Table',
        [SBQQ__StartDate__c] <= SELECTEDVALUE ( 'Calendar Table'[Date] )
            && [SBQQ__EndDate__c] >= SELECTEDVALUE ( 'Calendar Table'[Date] )
            && 'Table'[SBQQ__ProductName__c] = "Half Rent"
    )
RETURN
    IF (
        CALCULATE ( COUNTROWS ( 'Table' ), T ) > 0,
        CALCULATE ( SUM ( 'Table'[Total_Annual_Billable_Amount__c] ), T ),
        CALCULATE (
            SUM ( 'Table'[Total_Annualised_Rent__c] ),
            'Table'[SBQQ__ProductName__c] = "Office"
        )
    )

 

1.jpg


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.