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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
mangchaaBI
Helper II
Helper II

Days Difference Between 2 Data

Hi everyone,

 

Looking for guidance/assistance again 🙂

 

Not sure if I can explain this properly but I would want to transform this table with a unique EntityCode, their Notelogs (NoteCode which are also unique, and the Date when the Notes were created into something that will get the average number of days in between their calls 

 

Desired output is at the bottom where in it summarizes the average days per EntityCode

 

mangchaaBI_0-1690254776639.png

 

Thank you in Advance!

1 ACCEPTED SOLUTION
Ritaf1983
Super User
Super User

Hi @mangchaaBI 

To achieve your goal you need at the first step to add a calculated column for days diff :

DaysBetweenNextRow =
VAR CurrentEntity = 'table'[EntityCode]
VAR CurrentDate = 'table'[DateCreated]
VAR NextDate =
    CALCULATE(
        MIN('table'[DateCreated]),
        FILTER(
            'table',
            'table'[EntityCode] = CurrentEntity &&
            'table'[DateCreated] > CurrentDate
        )
    )
RETURN
    IF(ISBLANK(NextDate), BLANK(), DATEDIFF(CurrentDate, NextDate, DAY))
Ritaf1983_0-1690256719622.png

2. Add measures for average and count:

averaDays = averagex(values('Table'[EntityCode]),AVERAGE('Table'[DaysBetweenNextRow]))
Ritaf1983_1-1690256851972.png
count calls = DISTINCTCOUNT('Table'[NoteCode])
Ritaf1983_2-1690256904992.png

Link to a sample file 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

1 REPLY 1
Ritaf1983
Super User
Super User

Hi @mangchaaBI 

To achieve your goal you need at the first step to add a calculated column for days diff :

DaysBetweenNextRow =
VAR CurrentEntity = 'table'[EntityCode]
VAR CurrentDate = 'table'[DateCreated]
VAR NextDate =
    CALCULATE(
        MIN('table'[DateCreated]),
        FILTER(
            'table',
            'table'[EntityCode] = CurrentEntity &&
            'table'[DateCreated] > CurrentDate
        )
    )
RETURN
    IF(ISBLANK(NextDate), BLANK(), DATEDIFF(CurrentDate, NextDate, DAY))
Ritaf1983_0-1690256719622.png

2. Add measures for average and count:

averaDays = averagex(values('Table'[EntityCode]),AVERAGE('Table'[DaysBetweenNextRow]))
Ritaf1983_1-1690256851972.png
count calls = DISTINCTCOUNT('Table'[NoteCode])
Ritaf1983_2-1690256904992.png

Link to a sample file 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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