2 Replies Latest reply on Jun 27, 2017 9:48 AM by Joe Oppelt

# Help needed for condition-based calculated fields

I am trying to build ratios such as "if filter_field = X then sum(Y)" divided by "if filter_field = Z then sum(Y)". The ratio will be summing the same measure (in this case, 'Y') based on the different 'field_field' values. I tried building IF statements with the ratio such as this and I am getting the same values from each IF statement.

Really need your help here! Thanks a lot in advance.

• ###### 1. Re: Help needed for condition-based calculated fields

I've done this before using LODs I believe. Im not sure if its the best way to go about it, but

'SUM({FIXED [filters/fields applied]: SUM(IF [filter_field] = X then [Y] END)})/SUM({FIXED [filters/fields applied]: SUM(IF [filter_field] = Z then [Y] END)})'

should result in what you're looking for.

• ###### 2. Re: Help needed for condition-based calculated fields

You can embed IF logic inside your SUM() function.

SUM( if filter_field = X then [Y] END )  / SUM( if filter_field = Z then [Y] END)