Mismatched Aggregation - HELP!

Hi there,

I’m facing some issues writing a formula. I’ve created a formula called Discovery Formula to calculate the percentage.

countIf(Id, isNotNull({Discovery_Entry_Date__c}) AND StageName = 'Closed Won')/countIf(Id, 
isNotNull({Discovery_Entry_Date__c}))

The problem I’m encountering is that I have a field named StageName, which is a dimension field containing values from A to E. My goal is to use an IF-ELSE statement to check if the “StageName” is equal to ‘A,’ and if so, use the “Discovery Formula”; otherwise, use the “QSO Formula,” which is the same as the “Discovery Formula” but with a different field.

ifelse({StageName} = 'A', {Discovery Formula}, {QSO Formula})

I’m encountering a mismatched aggregation error. Can someone please help me understand what I am doing wrong here and how this can be corrected?

Thank you for your assistance.

@simantsah, mismatched aggregation error refers to a calculation that is using an aggregate function along with a non-aggregate function. So review the calculations for Discovery formula and QSO formula to check if both are using aggregate functions such as sum/min/max/avg etc and if not then update the calculations such that both of these calculations are using aggregate functions or neither using aggregate function.

Hello @DeepakS,

Like I mentioned in my above post, both these calculations are just same.

Discovery is

countIf(Id, isNotNull({Discovery_Entry_Date__c}) AND StageName = 'Closed Won')/countIf(Id, 
isNotNull({Discovery_Entry_Date__c}))

and QSO is

countIf(Id, isNotNull({QSO_Entry_Date__c}) AND StageName = 'Closed Won')/countIf(Id, 
isNotNull({QSO_Entry_Date__c}))

however, as soon as I write the final calculation that is
ifelse({StageName} = 'A', {Discovery Formula}, {QSO Formula})
I get a mismatched error. Can you help me understand what could be the reason behind it?

It’s in regards to your if statement and the first check. You are checking it at a row level and then wanting to return an aggregation. Try this.

ifelse(firstValue({StageName},[{StageName} ASC],[{StageName}]) = 'A', {Discovery Formula}, {QSO Formula})