Hi Vaibhav,
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 learn more about Tableau, go through this tutorial
https://intellipaat.com/blog/tutorial/tableau-tutorial/introduction-tableau/