Forum Discussion

space83's avatar
space83
Icon for Helper IV rankHelper IV
5 years ago
Solved

calculate average by selected year

Below is example of my data source:

 

 

How can I create measure to calculate average 'TotalDays' for year 2020?

 

I can do it simply in mssql but in DAX it become more complicated.

  • space83 

    Create this measure if you do not have a date table linked.

    Avg Total Days = 
    
    CALCULATE(
        AVERAGE(Table[Total Days]),
        FILTER(
            'Table1',
            Table1[Order Date] >= DATE(2020,1,1) && Table1[Order Date] <= DATE(2020,12,31))
    )
    
    

    ________________________

    If my answer was helpful, please consider Accept it as the solution to help the other members find it

    Click on the Thumbs-Up icon if you like this reply 🙂

    YouTube  LinkedIn

  • space83 , Try a measure like

    CALCULATE(AVERAGE(Table[Total Days]),FILTER(Table, year(Table[Order Date]) =2020))

2 Replies

  • space83 

    Create this measure if you do not have a date table linked.

    Avg Total Days = 
    
    CALCULATE(
        AVERAGE(Table[Total Days]),
        FILTER(
            'Table1',
            Table1[Order Date] >= DATE(2020,1,1) && Table1[Order Date] <= DATE(2020,12,31))
    )
    
    

    ________________________

    If my answer was helpful, please consider Accept it as the solution to help the other members find it

    Click on the Thumbs-Up icon if you like this reply 🙂

    YouTube  LinkedIn

  • space83 , Try a measure like

    CALCULATE(AVERAGE(Table[Total Days]),FILTER(Table, year(Table[Order Date]) =2020))