Skip to main content
Solved

"Long" formula issue

  • December 3, 2022
  • 3 replies
  • 26 views

Forum|alt.badge.img+6

Hello,

I'm totally new in the formula game, I created mine by putting pieces of tutorials together and using answers obtained here (by the way, thanks to the community!)

That's the deal :

When my cell x show 1h, I need to show 0
When my cell x show 2h, I need to show 0
When my cell x show 3h, I need to show 0
When my cell x show 4h, I need to show 1
When my cell x show 5h, I need to show 2
When my cell x show 6h, I need to show 0

I wrote :

IF( OR( {Durée estimée} = "1h", {Durée estimée} = "2h", {Durée estimée} = "3h" {Durée estimée} = "6h" ), "0" ) IF( OR( {Durée estimée} = "4h", ), "1" ) IF( OR( {Durée estimée} = "5h", ), "2"



I do not yet master the closing of the command and I think it comes from there

Do you have an idea please?

Best answer by Andrey_Kovalev

@alternazYou can write the formula this way:

IF( OR( {Text} = "1h", {Text} = "2h", {Text} = "3h", {Text} = "6h" ), "0", IF({Text} = "4h", "1", IF({Text} = "5h", "2" ) ) )

3 replies

Andrey_Kovalev
Forum|alt.badge.img+20
  • Inspiring
  • Answer
  • December 3, 2022

@alternazYou can write the formula this way:

IF( OR( {Text} = "1h", {Text} = "2h", {Text} = "3h", {Text} = "6h" ), "0", IF({Text} = "4h", "1", IF({Text} = "5h", "2" ) ) )

kuovonne
Forum|alt.badge.img+29
  • Brainy
  • December 4, 2022

Do you want a number or a text string that looks like a number? If you want an actual number, remove the quotes around the numbers.

You might also consider using a SWITCH() instead of nested IF().

SWITCH( {Durée estimée},

"4h", 1,

"5h", 2,

0

)


Forum|alt.badge.img+6
  • Author
  • Inspiring
  • December 4, 2022

@alternazYou can write the formula this way:

IF( OR( {Text} = "1h", {Text} = "2h", {Text} = "3h", {Text} = "6h" ), "0", IF({Text} = "4h", "1", IF({Text} = "5h", "2" ) ) )

Hi Andrey, perfect answer, thanks a lot 🙂