Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
datanibbler
Champion
Champion

Formula simplification

Hi,

I had two rather complex formulas for the calculation of workdays_so_far_this_year (Mo-Fri) and days_so_far_this_year (Mo-Sun).

They were

- SUM({1<%Datum = {">=$(=makedate(year(today()), 1, 1))<$(=DATE(v_today_num))" }>} Werktag)  [for workdays]

  (where >Werktag< is a binary field - 1 for (Mo-Fri), 0 for (Sat-Sun)

- COUNT({1<%Datum = {">=$(=makedate(year(today()), 1, 1))<$(=DATE(v_today_num))" }>} Werktag)  [for days]

Someone (sorry, it was offhand, so I didn't remember clearly) told me here on the forum how I could calculate the workdays_YTD much easier:

=> floor(reloadtime()) - yearstart(reloadtime()) - that works fine because the app is reloaded daily.

=> Is there also a way I can simplify the other formula, too? I'm sure that would result in a performance win, however small, as these formulas are present in every one of my apps.

Thanks a lot!

Best regards,

DataNibbler

P.S.: Ceterum censeo - there should be, among others, a category for posts rgd. variables to make those easier discernable.

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

How about:

NetWorkDays(YearStart(Today()), Today())

Regards

Jonathan

PS: replace Today() with reload time or variable as required

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

2 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

How about:

NetWorkDays(YearStart(Today()), Today())

Regards

Jonathan

PS: replace Today() with reload time or variable as required

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
datanibbler
Champion
Champion
Author

Hi Jonathan,

bull's_eye 😉 That's going to work.

I will put those two variables in a qvs file - they are needed in every app...