Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
JustinRamsey
Creator
Creator

Exclude Weekends from Calculation

I am in need of assistance writing a formula to give me the time between two time stamps excluding weekends. See image for the data. I want the end result to be as in the chart with days and the decimal not strictly the number of days as it is below just excluding the weekends. Networkdays wont work with the set analysis and using time. Formulas for columns 

Picking =SUM({<%KEY_ARBPL={2001}>}Date_Time)

RGA= SUM({<%KEY_ARBPL={2000}>}Date_Time)

Difference = Column(2)-Column(1)

JustinRamsey_1-1644006317174.png

 

Labels (2)
1 Solution

Accepted Solutions
Thiago_Justen_

Hey @JustinRamsey 

You could try this:

Difference = NetWorkDays(Column(1),Column(2))

Hope it helps you.

Regards 

Thiago Justen Teixeira Gonçalves
Farol BI
WhatsApp: 24 98152-1675
Skype: justen.thiago

View solution in original post

5 Replies
Thiago_Justen_

Hey @JustinRamsey 

You could try this:

Difference = NetWorkDays(Column(1),Column(2))

Hope it helps you.

Regards 

Thiago Justen Teixeira Gonçalves
Farol BI
WhatsApp: 24 98152-1675
Skype: justen.thiago
anat
Master
Master

considering 2 variables:

v1 = 2020-08-21 20:00:00 (older timestamp)

v2 = 2020-08-24 21:00:00 (newer timestamp)

This expression will use the NetWorkDays function to get the working days (excluding weekends), and the second part will calculate the difference on the time part:

=interval((NetWorkDays('$(v1)', '$(v2)') - 1) + (frac('$(v2)') - frac('$(v1)')),'hh')

JustinRamsey
Creator
Creator
Author

This formula works to get the total days but only gives the whole number of days. Would like to see the number of days and a decimal for the amount of hours. 

 

JustinRamsey
Creator
Creator
Author

I cannot get this to give results. I am not sure if I am defining the variables wrong or not. Also attempted to use just the columns instead of variables to no avail. Variable definitions below. I will admit I have not used variables much so I may be going about that portion incorrectly. 

 

JustinRamsey_0-1644236222196.png

 

JustinRamsey
Creator
Creator
Author

Actually discussed with the end user and they agreed straight days only would be sufficient for the needs. Thanks!