Skip to main content
Question

Alternative to long nested if

  • Jun 10, 2025 7:23 AM UTC
  • 3 replies
  • 394 views

Forum|alt.badge.img

Hello!

I seem to face a problem when constructing a trial balance for which i use nested ifs. So the formula goes like this 

IF('GL Accounts'='GL Accounts'."Revenue" ,'Revenue Staging',IF('GL Accounts'='GL Accounts'."Other income" ,'Other Income staging'))

So the condition is different for each list item in GL Account dimension (Which has 40 items)

When we try to use the nested ifs, it doesn’t allow us beyond 17 loops. Cannot use the switch statement as we have a different criteria for each list item. 

Have you guys gone through such a situation and found an alternative to long nested loops?

Thanks in advance for your help!

3 replies

Stef
Employee
Forum|alt.badge.img+14
  • Employee
  • Jun 10, 2025 7:39 AM UTC

Hello ​@Aravind !

If a SWITCH is not feasible (that would be the preferred option) what you could try is the following structure:

'Revenue Staging' [FILTER: 'GL Accounts'='GL Accounts'."Revenue" ] +
'Other Income staging' [FILTER: 'GL Accounts'='GL Accounts'."Other income"]

The example above should also work with SWITCH, but I’m unaware of any other conditions you might have but feel free to disclose them so we can review if using SWITCH is an option for your use case.


Forum|alt.badge.img
  • Author
  • Apprentice Author
  • Jun 10, 2025 7:48 AM UTC

Thanks Stef for the fast response! Appreciate it!

Will try with switch and filter and post the result here.


Forum|alt.badge.img
  • Author
  • Apprentice Author
  • Jun 10, 2025 5:32 PM UTC

It works. The arguments inside the switch metric must match that of the target metric. Thanks Stef!