6 Replies Latest reply on Nov 5, 2018 8:00 AM by Shaquelle Jacobs

# Error

Hi All,

how can i find the solution to this error. i want to use the MDBF as my calculation to get the MDBF for 12 months rolling and previous 12 months rolling but is saying  cannot mix aggregate and non aggregate comparison or results in if expression ?

• ###### 1. Re: Error

Hi Shaquelle,

This is the most common error that you would get in Tableau. It occurs when you return an aggregate in a logical calculated field, in this case MDBF. To resolve it use ATTR() around your date field, this function allows you to aggregate a dimension.

Cheers,

Sasha

1 of 1 people found this helpful
• ###### 2. Re: Error

Hi Shaquelle,

It in addition to Sasha's comment, it appears that you are missing an "ELSE" in your statement, which will continue to cause an error.

Claire Smith

• ###### 3. Re: Error

Hi Sasha,

i was able to add the sum and it worked perfectly fine.

sum(if ([Date Reported]) >= DATEADD('month',-12, [Selected Date ])then [Daily Miles] END)

/

sum([Daily Rc Cnt])

Also the ATTR() was giving me Null Values.

i am working on the 12 Month Previous. with the ATTR i am not getting any values

if ATTR([Date Reported]) >= DATEADD('month',-24,[Selected Date ]) and ATTR([Date Reported]) <= DATEADD('month',-12,[Selected Date ]) then sum([Daily Fuel])/sum([Daily Rc Cnt])

END

Sincerely,

Shaquelle

• ###### 4. Re: Error

Hi Claire,

can you please elaborate on the else statement if i am only trying to get one value. the sum of both will give me the MDBF.

Sincerely,

Shaquelle

• ###### 5. Re: Error

Hi Shaquelle,

I see your response to Sasha was that you go the statement to work, so maybe I misspoke! Based off my own experience, and the syntax example in Tableau, I've always used "ELSE". Thanks!

Claire Smith

1 of 1 people found this helpful
• ###### 6. Re: Error

Hi Claire,

Thank you so much.

Sincerely,

Shaquelle