Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Example:
If you want to display the name of the top city according to number of units sold, here is code you could use. Here we use membersSum to loop through each city for the total units.

Code Block

top = '';
topUnit = 0;

membersSum('[L_CITIES]') {
  if (M_UNIT>topUnit){
    topUnit = M_UNIT
    top = memberValue()
  }
}

return top;

You can also write the formula in this way:

Code Block

top = '';
topUnit = 0;

membersSum('[L_CITIES]') {
  topUnit = M_UNIT
}

membersSum('[L_CITIES]') {
  if (M_UNIT > topUnit){
    topUnit = M_UNIT
    top = memberValue()
  }
}

return top;

If you want to display the bottom city with least total units. Here it is:

Code Block

bottom = ''
bottomUnit = 0

membersSum('[L_CITIES]') {
  bottomUnit = M_UNIT
}

membersSum('[L_CITIES]') {
  if (M_UNIT < bottomUnit){
    bottomUnit = M_UNIT
    bottom = memberValue()
  }
}

return bottom;

Here is how the result will look like in the view:

...

Image Added

Next Steps

List siblings