5 Replies Latest reply: Nov 18, 2015 5:49 AM by Sunny Talwar

# SUM field if respect a condition?

Hi ,

I need to create an expression that is the sum of WORK TIME of the machine and AVAIBLE TIME of the MACHINE.

Code Causal
Causal Description
Time (H)
210WORK1
505Broken Machine2
300Machine OFF7
504Maintenance Machine3
210 WORK2

• The "Available Time "  is the sum of Duration without the row with "code causal" =300

My expression is :

Available_Time = if( Code Causal<>300,Sum(Time),0)

• The "Work Time "  is the sum of Duration with only the row "code causal" =210

My expression is :

Work_Time = if( Code Causal=210,Sum(Time),0)

But for the Work time the expression doesn't work, no result.

After i would use these expressions to create one KPI, that is the percert of Work Time / Available_Time.

Could you help me?

Thanks a lot

Fede

• ###### Re: SUM field if respect a condition?

I suggest using something we call "Set Analysis" instead of IF statements.

For Work_Time:

sum({< [Code Casual] = {210} > } Time)

For Available_Time:

sum({< [Code Casual] -= {300} > } Time)

• ###### Re: SUM field if respect a condition?

Try it with set analysis instead:

Available_Time = Sum({<Code Causal ={'*'} - {300}>} Time)

Work_Time = Sum({<Code Causal ={200}>} Time)

• ###### Re: SUM field if respect a condition?

Thanks Sunny!!!

It works fine!!!

• ###### Re: SUM field if respect a condition?

Even with the space in the name "Code Causal"? That is a surprise to me.

• ###### Re: SUM field if respect a condition?

Hahahaha I think he must have added it in his code