Forum Discussion
DonLarson
6 years agoQrew Elite
Andrea,
Try this:
// Calculate the Vehicles Per Tech
var number VehiclesPerTech =If ([Vehicle per technician] = "Yes", ToNumber([No of Technicians]);
// Calculate the Vehicles Per Crew
var number VehiclesPerCrew = If ([Vehicle per crew] = "Yes", ToNumber([No of Crew]);
// Calculate the Techs Per Vehicle, Account for the case where the denominator is zero
var number TechPerVehicle = if( $VehiclesPerCrew=0, 0, $VehiclesPerTech/$VehiclesPerCrew);
// Control the UI to show a Null Value of the answer is Zero
if ( $TechPerVehicle=0,null, $TechPerVehicle)
------------------------------
Don Larson
Paasporter
Westlake OH
------------------------------
Try this:
// Calculate the Vehicles Per Tech
var number VehiclesPerTech =If ([Vehicle per technician] = "Yes", ToNumber([No of Technicians]);
// Calculate the Vehicles Per Crew
var number VehiclesPerCrew = If ([Vehicle per crew] = "Yes", ToNumber([No of Crew]);
// Calculate the Techs Per Vehicle, Account for the case where the denominator is zero
var number TechPerVehicle = if( $VehiclesPerCrew=0, 0, $VehiclesPerTech/$VehiclesPerCrew);
// Control the UI to show a Null Value of the answer is Zero
if ( $TechPerVehicle=0,null, $TechPerVehicle)
------------------------------
Don Larson
Paasporter
Westlake OH
------------------------------
AndreaPahor
6 years agoQrew Cadet
Thanks, Don - much appreciated.
I omitted some key information:
No of Technicians / No of Crew can be unspecified (TBD), in which case the formula should return null.
For example, I want a result of null if Vehicle per technician = "Yes" and No of Technicians = "TBD".
How would I build this into your suggestion?
------------------------------
Andrea Pahor
------------------------------
I omitted some key information:
No of Technicians / No of Crew can be unspecified (TBD), in which case the formula should return null.
For example, I want a result of null if Vehicle per technician = "Yes" and No of Technicians = "TBD".
How would I build this into your suggestion?
------------------------------
Andrea Pahor
------------------------------
- DonLarson6 years agoQrew EliteAndrea,
Updated for that business case and fixed the 1st If Statement.
// Calculate the Vehicles Per Tech. Gives us the Number of Technicians or Zero
var number VehiclesPerTech =If ([Vehicle per technician] = "Yes", ToNumber([No of Technicians],0);
// Calculate the Vehicles Per Crew, Account for TBD in the Number of Technicians. Gives us the Number of Technicians or Zero
var number VehiclesPerCrew = If ([Vehicle per crew] = "Yes" and [No of Technicians]<>"TBD" , ToNumber([No of Crew],0);
// Calculate the Techs Per Vehicle, Account for the case where the denominator is zero
var number TechPerVehicle = if( $VehiclesPerCrew=0, 0, $VehiclesPerTech/$VehiclesPerCrew);
// Control the UI to show a Null Value of the answer is Zero. This is the objective of the formula.
if ( $TechPerVehicle=0,null, $TechPerVehicle)
------------------------------
Don Larson
Paasporter
Westlake OH
------------------------------- AndreaPahor6 years agoQrew CadetThank you, Don.
------------------------------
Andrea Pahor
------------------------------