Forum Discussion
SebL
4 years agoFrequent Visitor
12-month rolling calculation with two moving time variables
Hi Folks, I am using the September 2021 Report Server version of Desktop. I need to design a measure for a line graph that displays the 12-month rolling costs every quarter (and month in a s...
- Anonymous4 years ago
Hi SebL ,
You need a calendar table and use the calendar table to create relationships with 'Costs Table' and 'Days Paid Table'.
Calendar table:
Relationships:
Then please create these measures:
Sum of NbDays = IF ( ISINSCOPE ( 'Calendar'[Quarter] ) || ISINSCOPE ( 'Calendar'[Month] ), CALCULATE ( SUM ( 'DaysPaidTable'[NbDays] ), 'DaysPaidTable'[ReferenceNumber] = MAX ( 'DaysPaidTable'[ReferenceNumber] ) ) )12-month rolling costs = VAR _start = MAX('Calendar'[Year])*100+MIN('Calendar'[MonthNum]) VAR _end = _start+100 VAR _result = IF ( [Sum of NbDays] >= 180, CALCULATE ( SUM ( 'CostTable'[Amount] ), FILTER ( ALL('Calendar'), 'Calendar'[Year-Month]>=_start&&'Calendar'[Year-Month]<=_end ) ) ) RETURN _resultTest result:
The PBIX file is attached for reference.
Best Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data
SebL
4 years agoFrequent Visitor
I want to add that the ReferenceNumber is the field used to group the NbDays sums in the Days Paid Table and determine inclusion in the Costs Table.