Forum Discussion
Volume Calculation
- 5 years ago
Hi Anonymous ,
You may create a measure like DAX below to get diff value per month. While it won't achieve your requirement for the layout of Matrix visual completely, you may try to put [Equipment]and [MeterName] into Rows box of Matrix, put [Category] into Columns box, put [Month] and [Diff Value per month] into Values box.
Diff Value per month = VAR _PreMonth = CALCULATE ( SUM ( Table1[MeterValue] ), FILTER ( ALLEXCEPT ( Table1, [Category], [Equipment], [MeterName] ), YEAR ( Table1[Date] ) = YEAR ( MAX ( Table1[Date] ) ) && MONTH ( Table1[Date] ) = MONTH ( MAX ( Table1[Date] ) ) - 1 ) ) VAR _CurMonth = CALCULATE ( SUM ( Table1[MeterValue] ), FILTER ( ALLEXCEPT ( Table1, [Category], [Equipment], [MeterName] ), YEAR ( Table1[Date] ) = YEAR ( MAX ( Table1[Date] ) ) && MONTH ( Table1[Date] ) = MONTH ( MAX ( Table1[Date] ) ) ) ) RETURN _CurMonth - _PreMonthBest Regards,
Amy
Community Support Team _ Amy
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586.
The basic pattern is:
Column =
VAR __Current = [Value]
VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])
VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
__Current - __Previous