Aging Days between two days

looking for help w/ this measure, It returns expected result I need.
which are, the number of days aging when the [D Date] is blank. when not blank it returns a blank…no number.

NOW I need it to return ALSO the R[D Date] - R[E Date]…# of days.

here’s the measure:

AgingDays = 
    VAR AvgDate =
        MAX( CalendarFree[Date] )
    RETURN
        CALCULATE (
           AVERAGEX(XTR,
            1.*(IF(ISBLANK(R[D Date]), AvgDate-R[E Date],
                    R[D Date]-R[E Date]
                    )
                    )+1
                    ),
                 
            KEEPFILTERS ( R[E Date] < AvgDate ),
           KEEPFILTERS ( R[Effective D Date] > AvgDate )
    
       )```

and also the a 2nd measure needed where it does the opposite of what I pasted above, R[D Date] - R[E Date] for the period selected in my date slicer.

thank you in advance,

Frankee

I’m sorry but i don’t understand.

Are you using EDNA Date Table?
Do you have a pbix file that you can share.

Have you tried DataMentor/EDNA AI tools built in the EDNA platform.

thanks
Keith