Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago

DAX for rolling average, formula error

I'm trying to calculate the average number of invoices vouchered or the past 5 days, however my DAX returns an error

 

 

"Calculation error in measure 'vouchered'[Measure]: a table of multiple values was supplied where a single value was expected."

 

This is my DAX:

Measure = CALCULATE(
    AVERAGEX(vouchered, COUNT(vouchered[Invoice Number])),
    FILTER(
        vouchered,
        DATESBETWEEN(
				'vouchered'[Created Date].[Date],
				DATEADD(LASTDATE(vouchered[Created Date]), -5, DAY),
				DATEADD(LASTDATE(vouchered[Created Date]), 1, DAY)
        )
    )
)

What's wrong with my code?

 

Sample data:

https://docs.google.com/spreadsheets/d/1rc2FTwyysZz8HseGIAf6UWK0uL_k9_l2L9QYgiDD0-I/edit?usp=sharing

3 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      I changed it, but I'm still getting an error. Here's my latest function:

      Measure = CALCULATE(
          AVERAGEX(vouchered, COUNT(vouchered[Invoice Number])),
          FILTER(
              ALLEXCEPT(vouchered, vouchered[Created Date].[Date]),
              DATESBETWEEN(
      				'vouchered'[Created Date].[Date],
      				LASTDATE(vouchered[Created Date].[Date])-5,
      				LASTDATE(vouchered[Created Date].[Date])
              )
          )
      )
      • Anonymous's avatar
        Anonymous
        Not applicable

        hey Anonymous 

         

        try using quick measures to get your past 5 days average.

         

        kind regards;

        HiltonM