Forum Discussion

czuniga's avatar
czuniga
Helper III
5 years ago
Solved

Weighted Average

I have a dataset similar to this: 

 

Claim #DateSubmittedDate Paid# Of Days Between Date Submitted & DatePaid OR # Of Days Since Submitted
543213/1/20213/15/202114
543213/2/20213/16/202114
543213/3/20213/17/202114
543213/4/20213/18/202114
543213/5/20213/19/202114
543213/6/20213/20/202114
543213/7/20213/21/202114
543213/8/20213/22/202114
543213/9/20213/23/202114
543213/10/20213/24/202114
543213/11/20213/25/202114
543213/12/20213/26/202114
543213/13/20213/27/202114
543213/14/20213/28/202114
543213/15/20213/29/202114
543213/16/2021 13
543213/17/2021 12
543213/18/2021 11
543213/19/2021 10
543213/20/2021 9
543213/21/2021 8
543213/22/2021 7
543213/23/2021 6
543213/24/2021 5
543213/25/2021 4

I need to get the average of the "# Of Days Between Date Submitted & DatePaid OR # Of Days Since Submitted" that includes all of the rows with no pay date, but of the rows that do have a pay date, only those that have a pay date within the last 30 days. 

  • Hey czuniga ,

     

    the following measure should fulfil your criteria:

    Average if not paid or 30 days =
    CALCULATE(
        AVERAGE( myTable[# Of Days Between Date Submitted & DatePaid OR # Of Days Since Submitted] ),
        FILTER(
            myTable,
            myTable[Date Paid] = BLANK() || DATEDIFF( myTable[Date Paid], TODAY(), DAY ) <= 30
        )
    )

     

    If you need any help please let me know.
    If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
     
    Best regards
    Denis
     
     

3 Replies

  • selimovd's avatar
    selimovd
    Most Valuable Professional

    Hey czuniga ,

     

    the following measure should fulfil your criteria:

    Average if not paid or 30 days =
    CALCULATE(
        AVERAGE( myTable[# Of Days Between Date Submitted & DatePaid OR # Of Days Since Submitted] ),
        FILTER(
            myTable,
            myTable[Date Paid] = BLANK() || DATEDIFF( myTable[Date Paid], TODAY(), DAY ) <= 30
        )
    )

     

    If you need any help please let me know.
    If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
     
    Best regards
    Denis
     
     
    • czuniga's avatar
      czuniga
      Helper III

      If I wanted to view this same information on a rolling basis, how could I do that?

       

      I have this so far, but something is off: 

       

      Average if not paid or 30 days = CALCULATE( AVERAGE( Claims[Avg Days Outstanding] ), FILTER(
      ALLSELECTED(Claims ), Claims[DateService] <= max(Rolling_Calendar_Lookup[Date]) || DATEDIFF( Claims[PayDate], max(Rolling_Calendar_Lookup[Date]), DAY ) <= 30 ) )