Help with a formula calculation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BigBoss
    Senior Member
    • Nov 2023
    • 105

    #1

    Help with a formula calculation



    Hello friends, please, how can I calculate only the requests with the status "Validated"?

    Currently, I am using a formula that counts the record lines, but this affects the calculation.


    montant = entity\sumRelated('avan2', 'montant');
    reste = entity\sumRelated('avan2', 'reste');​​


    The records are linked by a many-to-many relationship.

    If I'm not mistaken, you need to retrieve all the related records, check the status of each one, and then count only those with the status "Validated".
    ​
    ​


    ​

    Click image for larger version

Name:	image.png
Views:	362
Size:	80.2 KB
ID:	114753​
  • victor
    Active Community Member
    • Aug 2022
    • 1246

    #2
    You should create a Primary Filter (if it hasn't already been created) and use it in the formula:https://docs.espocrm.com/administrat...titysumrelated.

    And your formulas should look something like this:
    Code:
    montant = entity\sumRelated('avan2', 'montant', 'Validated');​​
    reste = entity\sumRelated('avan2', 'reste', 'Validated');​​​
    Primary Filters for developers: https://docs.espocrm.com/development...erclassnamemap.
    Primary Filters by means of Report Filters: https://docs.espocrm.com/user-guide/...report-filters.
    You can find the list of Primary Filters in Administration > Entity Manager > Ypur_entity_name > Details > Primary Filters.

    Comment

    Working...