Assuming your data looks like this
Date |
Amount |
02 August 2021 |
19 |
05 August 2021 |
18 |
31 August 2021 |
25 |
01 September 2021 |
29 |
05 September 2021 |
23 |
30 September 2021 |
31 |
04 October 2021 |
30 |
05 October 2021 |
30 |
31 October 2021 |
31 |
01 November 2021 |
38 |
05 November 2021 |
38 |
30 November 2021 |
44 |
01 December 2021 |
45 |
05 December 2021 |
42 |
31 December 2021 |
42 |
I have created a Return calculation, assuming you have a Calendar table. I have specified the DAX for the calendar table and the calculation below.
The idea of the calculation is to get the first day of the month value and the last day of the month value and use those to get the return of each month.
The calculation works using as x-axis the field Month
and Month Truncated
.
It's better practice to use a Calendar table because the number of scans done by the engine are fairly reduced, in contrast, to scan a fact table. Also, you can rely on the time intelligence formulas in DAX when you use a calendar table.
DAX: Calendar Table
Calendar =
ADDCOLUMNS (
CALENDAR ( MIN ( 'Table'[Date] ), MAX ( 'Table'[Date] ) ),
"Month", MONTH ( [Date] ),
"Month Truncated", DATE ( YEAR ( [Date] ), MONTH ( [Date] ), 01 )
)
DAX: Return Calculation
Return =
Return =
VAR CurrentMonth =
SELECTEDVALUE ( 'Calendar'[Month] )
VAR FirstDayMonth =
CALCULATE (
MIN ( 'Calendar'[Date] ),
'Calendar'[Month] = CurrentMonth,
'Calendar'[Date] IN VALUES ( 'Table'[Date] )
)
VAR LastDayMonth =
CALCULATE (
MAX ( 'Calendar'[Date] ),
'Calendar'[Month] = CurrentMonth,
'Calendar'[Date] IN VALUES ( 'Table'[Date] )
)
VAR FirstDayMonthValue =
CALCULATE ( MAX ( 'Table'[Amount] ), 'Table'[Date] = FirstDayMonth )
VAR LastDayMonthValue =
CALCULATE ( MAX ( 'Table'[Amount] ), 'Table'[Date] = LastDayMonth )
VAR ReturnCalculation =
DIVIDE ( LastDayMonthValue - FirstDayMonthValue, FirstDayMonthValue )
RETURN
ReturnCalculation
Output

Calendar Table as Date Table
Step 1

Step 2
