Hi everyone, I would like to share this comparison for feedback from the forum. Both formulas iterate the average time in status of total loans for each underwriter ( row ). It takes into account zero values as well as the total average ( total row ). Both have the same results on the matrix.
VERSION 1
VAR _oneValue = HASONEVALUE ( UWtracker[AssignedUW] )
VAR _avgx =
AVERAGEX (
ADDCOLUMNS (
SUMMARIZE ( UWtracker, UWtracker[Loan Number], UWtracker[Days] ),
"@Days",
CALCULATE (
IF (
NOT ( ISBLANK ( SELECTEDVALUE ( UWtracker[AssignedUW] ) ) ),
VALUES ( UWtracker[Days] )
)
)
),
[@Days]
)
VAR _result =
SWITCH ( TRUE (), _oneValue, _avgx + 0, _avgx )
RETURN
_result
VERSION 2
VAR _notBlank =
NOT ( ISBLANK ( SELECTEDVALUE ( Underwriters[AssignedUW] ) ) )
VAR _avgx =
AVERAGEX (
DISTINCT (
SELECTCOLUMNS (
UWtracker,
"@Loan", UWtracker[Loan Number],
"@Days", UWtracker[Days]
)
),
[@Days]
)
VAR _result =
SWITCH ( TRUE (), _notBlank, _avgx + 0, _avgx )
RETURN
_result
Version 1 visual rendered slightly faster on the performance analyzer.