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
jobf
Helper II
Helper II

Difference between application dates of products in a given location.

Hello. Please take a look at the table below:

Location  Period  Application  Date
P1  1st  1st application  01/01/2025
P1  2nd  1st application  01/02/2025
P1  1st  2nd application  01/20/2025
P1  2nd  2nd application  01/21/2025
P2  1st  1st application  01/05/2025
P2  2nd  1st application  01/06/2025
P2  1st  2nd application  01/15/2025
P2  2nd  2nd application  01/19/2025

 

I need a column or measure that shows the difference (days) between the current application of the period and the most recent date of the last application at a given location of the period. It would look something like this:

Location  Period  Application  DateDifference
P1  1st  1st application  01/01/2025 
P1  2nd  1st application  01/02/2025 
P1  1st  2nd application  01/20/202519
P1  2nd  2nd application  01/21/202519
P2  1st  1st application  01/05/2025 
P2  2nd  1st application  01/06/2025 
P2  1st  2nd application  01/15/202510
P2  2nd  2nd application  01/19/202513

 

If this is the first application, it should show a null value. One thing to keep in mind is that this table is just an example. Sometimes, there will be 12 or more applications in the same location.

2 ACCEPTED SOLUTIONS
Bibiano_Geraldo
Super User
Super User

Hi @jobf ,
you can achieve your goal by this DAX measure:

Difference = 
VAR CurrentDate = MAX('Table'[Date])
VAR CurrentApplication = SELECTEDVALUE('Table'[Application])
VAR Location = SELECTEDVALUE('Table'[Location])
VAR PreviousApplicationMaxDate =
    CALCULATE(
        MAX('Table'[Date]),
        FILTER(
            ALL('Table'),
            'Table'[Location] = Location &&
            'Table'[Application] <> CurrentApplication &&
            'Table'[Date] < CurrentDate
        )
    )
RETURN
IF(
    ISBLANK(PreviousApplicationMaxDate),
    BLANK(),
    DATEDIFF(PreviousApplicationMaxDate, CurrentDate, DAY)
)

 Your output will look like this:

Bibiano_Geraldo_0-1737483021120.png

 

View solution in original post

ThxAlot
Super User
Super User

Remember a rule of thumb, integer is the most preferrable data type in PBI, namely good for data compression and calculation as well. Turn columns Period and Application to integer.

 

ThxAlot_0-1737491899195.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



View solution in original post

2 REPLIES 2
ThxAlot
Super User
Super User

Remember a rule of thumb, integer is the most preferrable data type in PBI, namely good for data compression and calculation as well. Turn columns Period and Application to integer.

 

ThxAlot_0-1737491899195.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



Bibiano_Geraldo
Super User
Super User

Hi @jobf ,
you can achieve your goal by this DAX measure:

Difference = 
VAR CurrentDate = MAX('Table'[Date])
VAR CurrentApplication = SELECTEDVALUE('Table'[Application])
VAR Location = SELECTEDVALUE('Table'[Location])
VAR PreviousApplicationMaxDate =
    CALCULATE(
        MAX('Table'[Date]),
        FILTER(
            ALL('Table'),
            'Table'[Location] = Location &&
            'Table'[Application] <> CurrentApplication &&
            'Table'[Date] < CurrentDate
        )
    )
RETURN
IF(
    ISBLANK(PreviousApplicationMaxDate),
    BLANK(),
    DATEDIFF(PreviousApplicationMaxDate, CurrentDate, DAY)
)

 Your output will look like this:

Bibiano_Geraldo_0-1737483021120.png

 

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.