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: 
alwayslearning
Creator
Creator

IF and set analysis and time

Hi,

I have a IF statement, which has an expression which sums and converts various time fields.

=num(if((Sum(Log_In_duration)/60)=0,' ' ( (SUM(Time)+SUM(Time2)+ ((sum(Time3)/3600)+sum(Time4)))/60)

/Sum([Log_In_duration]/60)), '##0 %')

In addition to the above formula which works as is, I need the formula to only return date specific data.

I have created a variable titled vcurrentweek from a field "DATE" and was looking to do a SET Analysis for current week and perform the above.  However I am getting various errors and hoped someone could help.

Thanks

1 Solution

Accepted Solutions
Anil_Babu_Samineni

May be this?

=num(if((Sum(Log_In_duration)/60)=0,' ' ( (SUM({<DATE = {$(vcurrentweek)}>} Time)+SUM({<DATE = {$(vcurrentweek)}>} Time2)+ ((sum({<DATE = {$(vcurrentweek)}>} Time3)/3600)+sum({<DATE = {$(vcurrentweek)}>} Time4)))/60)

/Sum({<DATE = {$(vcurrentweek)}>} [Log_In_duration]/60)), '##0 %')

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful

View solution in original post

5 Replies
Anil_Babu_Samineni

May be this?

=num(if((Sum(Log_In_duration)/60)=0,' ' ( (SUM({<DATE = {$(vcurrentweek)}>} Time)+SUM({<DATE = {$(vcurrentweek)}>} Time2)+ ((sum({<DATE = {$(vcurrentweek)}>} Time3)/3600)+sum({<DATE = {$(vcurrentweek)}>} Time4)))/60)

/Sum({<DATE = {$(vcurrentweek)}>} [Log_In_duration]/60)), '##0 %')

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
devarasu07
Master II
Master II

Hi,

Another simplified way u can try like below using set analysis

Num(sum( {$<Log_In_duration={"=Sum(Log_In_duration)/60)=0"},Year={"$(=Max(Year))"},Week={$(vcurrentweek)}>} (Time2+(Time3/3600)+(Time4/60))/ (Log_In_duration/60) ),'#,##0%')

alwayslearning
Creator
Creator
Author

Thanks Anil,

This works perfectly.

*Note:If anyone uses the code above in the future, there is a , missing before the false statement begins.

alwayslearning
Creator
Creator
Author

Thanks Devarasu

Anil_Babu_Samineni

I am correcting myself

=num(if((Sum(Log_In_duration)/60)=0,' ', ( (SUM({<DATE = {$(vcurrentweek)}>} Time)+SUM({<DATE = {$(vcurrentweek)}>} Time2)+ ((sum({<DATE = {$(vcurrentweek)}>} Time3)/3600)+sum({<DATE = {$(vcurrentweek)}>} Time4)))/60)

/Sum({<DATE = {$(vcurrentweek)}>} [Log_In_duration]/60)), '##0 %')

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful