Forum Discussion
Help me customize the function.
- 1 year ago
Hi Avari_ya ,
Certainly. The issue with your original formula lies in the order and overlap of conditions inside the SWITCH(TRUE(), ...) block. In DAX, SWITCH(TRUE(), ...) evaluates each condition in order, and once it finds the first condition that evaluates to TRUE, it stops evaluating the rest. In your version, some overlapping conditions caused the function to return unintended results.
Here is a revised version of the function that simplifies the logic, checks the percentage thresholds in descending order, and deducts 5% from the bonus if the test score is missing:
Bonus Score Quality = VAR IBOBMaxBonus = 0.12 VAR ChatMaxBonus = 0.08 VAR MinBonus = 0.04 VAR Penalty = 0.05 VAR LineType = SELECTEDVALUE(PMI_Targets_Agents[Line]) VAR QualityScore = [Target Agent Volume Quality] VAR Target100 = [Target Agent Quality] VAR Target95 = [Target Agent Quality 0.95] VAR Target90 = [Target Agent Quality 0.9] VAR HasTest = NOT(ISBLANK([Target Agent T&D Test Score])) RETURN SWITCH( TRUE(), LineType = "IB" && QualityScore >= Target100, IBOBMaxBonus - IF(HasTest, 0, Penalty), LineType = "IB" && QualityScore >= Target95, ChatMaxBonus - IF(HasTest, 0, Penalty), LineType = "IB" && QualityScore >= Target90, MinBonus - IF(HasTest, 0, Penalty), LineType = "IB", 0, BLANK() )This version ensures that the proper bonus rate is selected based on the performance level, and it penalizes agents without test scores by reducing their bonus by 0.05. The conditions are ordered from highest to lowest target level so the logic flows correctly.
Best regards,
Hi Avari_ya ,
Just checking in to see if you query is resolved and if any responses were helpful. If so, kindly consider marking the helpful reply as 'Accepted Solution' to help others with similar queries.
Otherwise, feel free to reach out for further assistance.
Thank you.