Forum Discussion
JulietZhu
Helper IV
8 years agoAverage payment for previous month
I need average payment for last month. For example, if I choose any date for Feb, average payment for Jan need be calculated. Each day payment for Feb will be compared to overal average payment in J...
- 8 years ago
I downloaded and looked at your file. Only change I see to make is to remove the ".Date" part. Try this:
Avg_PreviousMonth_payment = CALCULATE ( AVERAGE ( DataFromDB[Payment_Amt] ), PREVIOUSMONTH ( CalendarTable[Date] ) ) - 8 years ago
One way to reduce is:
Creating a calculated column in your calendar table
DaysinMonth = DATEDIFF ( STARTOFMONTH ( CalendarTable[Date] ); ENDOFMONTH ( CalendarTable[Date] ); DAY ) + 1And in the measure:
TotalPayment_PreviousMonth = VAR DaysinPrevMonth = CALCULATE ( SELECTEDVALUE ( CalendarTable[DaysinMonth] ); PREVIOUSMONTH ( CalendarTable[Date] ) ) RETURN DIVIDE ( CALCULATE ( SUM ( DataFromDB[Payment_Amt] ); PREVIOUSMONTH ( CalendarTable[Date] ) ); DaysinPrevMonth )Regards
Victor
Lima - Peru
mattbrice
Solution Sage
8 years agoI downloaded and looked at your file. Only change I see to make is to remove the ".Date" part. Try this:
Avg_PreviousMonth_payment =
CALCULATE (
AVERAGE ( DataFromDB[Payment_Amt] ),
PREVIOUSMONTH ( CalendarTable[Date] )
)SQUILES
Helper I
7 years agoHI, I need to get the average of previous month to compare with the current month. I try to New Measure:
Prev_Month_Ave =
CALCULATE(AVERAGE('Query1'[DATO_46]),PREVIOUSMONTH(Query1[DATA_PERIODO]))
But give me (BLANK) result.
Any help please?
My data look like: