You need to sign in to do that
Don't have an account?
Evrydiki
validation to count sub-total based on other fields' values
Hi,
I have a field of total machines and some fileds giving the specs. The machines might be of type A or type B.
The user needs to fill in the total number of machines that need to be changed in a factory. Then, depending on the specs that the user will fill in for each of the changes (max 5 changes per request), I need to calculate how many machines are of type A and how many are of type B.
The number of machines for both types are calculated in formula [number] fields and I currently have this formula. However, this only takes into account the first spec:
IF((ispickval(Machine__c,'A')) ,(IF((ispickval(Machine2__c,'A')) ,(IF((ispickval(Machine3__c,'A')) ,(IF((ispickval(Machine4__c,'A')) ,(IF((ispickval(Machine5__c,'A')) ,(i__c+1), (i__c+1)) ), (i__c+1)) ), (i__c+1)) ), (i__c+1)) ), (i__c))
The above example refers to one of the machine types. "i" is a temp variable with an initial value of 0.
The MachineX__c fields can be either all blank or any of the fields can be filled in.
Could someone please help? Thanks!
Evrydiki
I have a field of total machines and some fileds giving the specs. The machines might be of type A or type B.
The user needs to fill in the total number of machines that need to be changed in a factory. Then, depending on the specs that the user will fill in for each of the changes (max 5 changes per request), I need to calculate how many machines are of type A and how many are of type B.
The number of machines for both types are calculated in formula [number] fields and I currently have this formula. However, this only takes into account the first spec:
IF((ispickval(Machine__c,'A')) ,(IF((ispickval(Machine2__c,'A')) ,(IF((ispickval(Machine3__c,'A')) ,(IF((ispickval(Machine4__c,'A')) ,(IF((ispickval(Machine5__c,'A')) ,(i__c+1), (i__c+1)) ), (i__c+1)) ), (i__c+1)) ), (i__c+1)) ), (i__c))
The above example refers to one of the machine types. "i" is a temp variable with an initial value of 0.
The MachineX__c fields can be either all blank or any of the fields can be filled in.
Could someone please help? Thanks!
Evrydiki
I am not sure to understand.
Are you trying to get 2 formula fields ( for Machine A & B ) which calculate how many there are for each type regarding the 5 Picklists ( Machine 1 -> 5 ) ?
Like :
Machine 1 -> A
Machine 2 -> B
Machine 3 -> A
Machine 4 -> A
Machine 5 -> B
Count(A) -> 3
Count(B) -> 2
If I am understanding it well, for getting those 2 results you need to create 2 Formula(number) fields :
Count(A) :
IF(ISPICKVAL(Machine1__c,'A'),1,0)+
IF(ISPICKVAL(Machine2__c,'A'),1,0)+
IF(ISPICKVAL(Machine3__c,'A'),1,0)+
IF(ISPICKVAL(Machine4__c,'A'),1,0)+
IF(ISPICKVAL(Machine5__c,'A'),1,0)
Count(B) :
IF(ISPICKVAL(Machine1__c,'B'),1,0)+
IF(ISPICKVAL(Machine2__c,'B'),1,0)+
IF(ISPICKVAL(Machine3__c,'B'),1,0)+
IF(ISPICKVAL(Machine4__c,'B'),1,0)+
IF(ISPICKVAL(Machine5__c,'B'),1,0)
All Answers
I am not sure to understand.
Are you trying to get 2 formula fields ( for Machine A & B ) which calculate how many there are for each type regarding the 5 Picklists ( Machine 1 -> 5 ) ?
Like :
Machine 1 -> A
Machine 2 -> B
Machine 3 -> A
Machine 4 -> A
Machine 5 -> B
Count(A) -> 3
Count(B) -> 2
If I am understanding it well, for getting those 2 results you need to create 2 Formula(number) fields :
Count(A) :
IF(ISPICKVAL(Machine1__c,'A'),1,0)+
IF(ISPICKVAL(Machine2__c,'A'),1,0)+
IF(ISPICKVAL(Machine3__c,'A'),1,0)+
IF(ISPICKVAL(Machine4__c,'A'),1,0)+
IF(ISPICKVAL(Machine5__c,'A'),1,0)
Count(B) :
IF(ISPICKVAL(Machine1__c,'B'),1,0)+
IF(ISPICKVAL(Machine2__c,'B'),1,0)+
IF(ISPICKVAL(Machine3__c,'B'),1,0)+
IF(ISPICKVAL(Machine4__c,'B'),1,0)+
IF(ISPICKVAL(Machine5__c,'B'),1,0)
thanks! it works!!