Calculated fields with clauses

I am setting up sugarCRM for a real estate administration company..

I have used the accounts module for buildings and apartments..
Each apartment is a member of the building they are in..

I have made a calculated field (count($members)) to show how many apartments fall under one building.. (this works)

Each apartment has a status field (dropdown) that is either 'Rented' or 'Available', I would like to count how many apartments are rented in each building.

In SQL it would look something like this:
SELECT *
FROM Building1
WHERE status = 'Rented'

How do I make this in sugar?

Parents Reply
  • Thanks for the replies.. I tried to use the formula you posted here and edited it to fit my data, then it would look like this?:

    countConditional($members,"account_type",createList("apartment","empty"))

    Given the account_type = apartment, and the condition that status_c = empty..

    This just gives me the same as count($members), since it does not take into account that the apartment has to be available before it counts them..

    Is there any other way to make this work? I do not just need to count apartments in a building, but apartments with a condition.. In this case, empty apartments

Children
No Data