CUSTOM Rollup with a Hierarchy
We had a scenario where the user want to see average on the DETAIL rows and the SUM of the averages on the TOTAL row in a matrix. The 'Calendar'[Full Date] column was on the rows and it was the lowest level of the hierarchy which include week, month, etc.
The 'Calendar'[Full Date] column represents a single day.
HASONEVALUE will return TRUE for a single day and FALSE otherwise. When FALSE, use SUMX to iterate over the days and calculate the SUM of the averages.
Here is the measure:
'Financial Summary'[Average Sales (With Rollup)] =
VAR AverageSales =
AVERAGEX('Financial Summary', 'Financial Summary'[TransactionAmount])
RETURN
IF (
HASONEVALUE('Calendar'[Full Date]),
AverageSales,
SUMX(VALUES('Calendar'[Full Date]), AverageSales)
)
VAR AverageSales =
AVERAGEX('Financial Summary', 'Financial Summary'[TransactionAmount])
RETURN
IF (
HASONEVALUE('Calendar'[Full Date]),
AverageSales,
SUMX(VALUES('Calendar'[Full Date]), AverageSales)
)
Comments
Post a Comment