Hi Ritu,
This happens when you are comparing a field with aggregate(field) such as 
IF [Sales] = MAX([Sales]) .......    Here this would throw an error same like yours.
To avoid this you can use Fixed LOD which converts the Aggregated measure into a single dimension to compare or use with a field. Aggregation such as MIN, MAX, SUM, AVG, etc.
IF [Sales] = { MAX([Sales]) } ...... would not throw an error.
So use Fixed LOD to do such comparisons
To know about Fixed LOD, 
https://www.edureka.co/blog/tableau-lod/