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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Average calculation based on dates

Hi 
I need to calculate the average time of these priorities and something is missing in my equation because it should only include the dates if "Afsluttet date" is blank and I know for a fact that all 1. priorities only have an "aflsuttet date"(enddate), so it should not appear in the graph. 
 
lavmads_1-1674031650070.png

 

Average time =
VAR _dato = MAX(Kalender[Date])
RETURN
AVERAGEX(
    CALCULATETABLE(
        Data,
        ALL(Kalender),
        Data[Registreret dato]<_dato && (Data[Afsluttet dato] > _dato || ISBLANK(Data[Afsluttet dato]))
    ),
    DATEDIFF(Data[Registreret dato], _dato, DAY)
)
 
What is wrong with the equation above?
 
Best regards,
Lisa 
2 REPLIES 2
Mahesh0016
Super User
Super User

@Anonymous 

Average time =
VAR _dato =
MAX ( Kalender[Date] )
RETURN
AVERAGEX (
FILTER (
Data,
CALCULATE (
ALL ( Kalender ),
Data[Registreret dato] < _dato
&& OR ( Data[Afsluttet dato] > _dato, ISBLANK ( Data[Afsluttet dato] ) )
)
),
DATEDIFF ( Data[Registreret dato], _dato, DAY )
)

 

@Anonymous If this post helps, please consider accept as solution to help other members find it more quickly and Appreciate your Kudos.

Anonymous
Not applicable

@Mahesh0016 

What is the right setup? Because if I copy past your equation it says something is wrong. 

 

VAR _dato =
MAX ( Kalender[Date] )
RETURN
AVERAGEX(
    FILTER (
    Data,
    CALCULATE(
    ALL (Kalender),
    Data[Registreret dato] < _dato
    && OR ( Data[Afsluttet dato] > _dato, ISBLANK ( Data[Afsluttet dato] ) )
    )
    ),
    DATEDIFF ( Data[Registreret dato], _dato, DAY )
)

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