Yes, Koushik’s solution is correct. We have to add the “PRE_AGG” into the rank calculation to bring the rank before the visual level calculation. Otherwise, in the ifelse calculation, the condition branch is post aggregation, while the true/false branch are before aggregation. That’s why Quick Sight return an error.