Forum Discussion
GrahamR99
6 years agoResolver I
If statement to build Time Range
Hello I have custom column that has this code. Talk_Time_Range = IF(Maintel_Data[Talk_Time_Seconds] >= 0 && Maintel_Data[Talk_Time_Seconds]<=30,"Under 30 secs",IF(Maintel_Data[Talk_Time_Seconds] >...
- 6 years ago
It works fine for me. It returns 1-2 minutes. I'd need to see your data to understand what is going on.
Rather than nested IF statements, consider switching to the SWITCH function. For example:
New Talk Time = SWITCH( TRUE(), Maintel_Data[Talk_Time_Seconds] >= 0 && Maintel_Data[Talk_Time_Seconds] <= 30, "Under 30 Seconds", Maintel_Data[Talk_Time_Seconds] > 30 && Maintel_Data[Talk_Time_Seconds] <= 60, "30-60 Seconds", Maintel_Data[Talk_Time_Seconds] > 60 && Maintel_Data[Talk_Time_Seconds] <= 120, "1-2 Minutes", Maintel_Data[Talk_Time_Seconds] > 120 && Maintel_Data[Talk_Time_Seconds] <= 180, "2-3 Minutes", Maintel_Data[Talk_Time_Seconds] > 180 && Maintel_Data[Talk_Time_Seconds] <= 240, "3-4 Minutes" )
edhans
6 years agoCommunity Champion
Excellent. Glad you got it sorted out, and learned a new function! 😁 SWITCH is so much easier to read and edit.
edhans
6 years agoCommunity Champion
By the way GrahamR99 I noticed a small bug in your code:
It will not handle 300 seconds. It will drop down to the "Over 6 hours" section. Make sure when you are coverting to SWITCH you fix that.
EDIT: actually, it is all of your code the rest of the way down. Seconds of exactly 420, 480, 540, etc. will fail.