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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Anonymous
Not applicable

Number of Days between the same products

Hi There,

I am trying to find the number of days between a same product being applied on a same field on the basis of application dates. Whenever a product is applied on the field, the date is recorded as Application Date. 

The report looks like:

ManishaKarki_0-1654862945880.png

and the measure I am using to calculate is:

No. Of Days =
CALCULATE(
  DATEDIFF(
    MIN('Table'[ApplicationDate]),
    MAX('Table'[ApplicationDate]), DAY
  ),
  ALLEXCEPT(
    'Table''Table'[Field]'Table'[Product]'Table'[Type]
  )
)

But this gives me the no. of days between the first and last application dates. What I am looking for is to caclculate no. of days between previous and next application dates.
As per the 1st and 2nd record in the report, No. of days should be 7 days (Previous date :17th June 2021 and Next date: 24 June 2021.
How to achieve this?

 

Appreciate your help.

 
 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
rohit_singh
Solution Sage
Solution Sage

Hi @Anonymous ,

Not sure is this is what you need but you can try creating this measure :

rohit_singh_1-1654868080573.png

Days since last application =

var _currdate = max(Products[Application Date])

var _nextdate =

CALCULATE(
max(Products[Application Date]),
FILTER(ALLEXCEPT(Products, Products[Type], Products[Product]), Products[Application Date] < _currdate
)
)

var _days =

CALCULATE(
DATEDIFF(_nextdate,_currdate,DAY))

RETURN
if(isblank(_days), 0, _days)

Kind regards,

Rohit


Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

View solution in original post

4 REPLIES 4
rohit_singh
Solution Sage
Solution Sage

Hi @Anonymous ,

Not sure is this is what you need but you can try creating this measure :

rohit_singh_1-1654868080573.png

Days since last application =

var _currdate = max(Products[Application Date])

var _nextdate =

CALCULATE(
max(Products[Application Date]),
FILTER(ALLEXCEPT(Products, Products[Type], Products[Product]), Products[Application Date] < _currdate
)
)

var _days =

CALCULATE(
DATEDIFF(_nextdate,_currdate,DAY))

RETURN
if(isblank(_days), 0, _days)

Kind regards,

Rohit


Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

Anonymous
Not applicable

It works as expected. Thank you so much for the quick solution.

johnt75
Super User
Super User

You can try

No of days =
VAR currentDate =
    SELECTEDVALUE ( 'Table'[Application date] )
VAR nextDate =
    SELECTCOLUMNS (
        CALCULATETABLE (
            TOPN ( 1, 'Table', 'Table'[Application date], ASC ),
            ALLEXCEPT ( 'Table', 'Table'[Field], 'Table'[Product], 'Table'[Type] ),
            'Table'[Application date] > currentDate
        ),
        "@val", 'Table'[Application date]
    )
RETURN
    DATEDIFF ( currentDate, nextDate, DAY )
Anonymous
Not applicable

I tried but it was giving me insufficient memory error.

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.

Top Solution Authors
Top Kudoed Authors