Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

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

1 Solution

Accepted Solutions
sunny_talwar

Try it with set analysis instead:

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

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

View solution in original post

5 Replies
oknotsen
Master III
Master III

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)

May you live in interesting times!
sunny_talwar

Try it with set analysis instead:

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

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

Not applicable
Author

Thanks Sunny!!!

It works fine!!!

oknotsen
Master III
Master III

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

May you live in interesting times!
sunny_talwar

Hahahaha I think he must have added it in his code