Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Ok, I undestand, but the actual expected numbers?
Using
=sum(if ( CapDatumAchterstand < FirstWorkDate( vToday-1,2),[CapInUrenAchterstand]))
for 2 workdays in the past (I noticed I need to subtract 1day for actually getting the correct results, because FirstWorkDate will also take the enddate into account).
I get:
Kstplts | Per Dag | Gevraagde Capaciteit | Cap. per aant. Dgn | In % | Achterstand t/m 1 dag terug | Achterstand t/m 2 dagen terug | sum(if ( CapDatumAchterstand < FirstWorkDate( vToday-1,2),[CapInUrenAchterstand])) |
---|---|---|---|---|---|---|---|
105 | 339 | 199 | 339 | 59% | 948 | 708 | 501,2 |
110 | 107 | 187 | 107 | 174% | 1899 | 1788 | 1666,51 |
115 | 60 | 85 | 60 | 142% | 36 | 20 | 6,88 |
120 | 58 | 38 | 58 | 67% | 88 | 78 | 66,08 |
125 | 45 | 62 | 45 | 139% | 173 | 162 | 144,18 |
130 | 38 | 2 | 38 | 6% | 12 | 12 | 11 |
150 | 38 | 5 | 38 | 13% | 161 | 160 | 159 |
Not sure if I understood correctly, because I think your above definitions will sum all CapInUrenAchterstand values before vToday resp. vToday-1.
If you want to sum the total of one workday ago, I would try something like:
=sum({<Date= {"$(=firstworkdate(today(),1))"}>} Value)
This will some Values of last friday. I used a set expression, but I think this should be equivalent:
=sum(if(Date = firstworkdate(today(),1), Value) )
If you want to sum the last two workdays, and it will not harm your results if you just include the non-working days, you could use something like
=sum({<Date= {">=$(=firstworkdate(today(),2))<=$(=firstworkday(today(),1))"}>} Value)
or
=sum(if(Date >= firstworkdate(today(),2) and Date <= firstworkdate(today(),1), Value))
You could use vToday (or $(vToday) ) instead of today() function, and you could also define your hoilday in the firstworkday function to exclude them also.
Hope this helps,
Stefan
Stefan,
Tanks a lot for your answer.
But i want count all hours in the past till one day or two days before Today without take into the calculation the saturday and sunday.
My week must have only five workdays.
Greetings
Gerrit
-
swuehl <qliktech@sgaur.hosted.jivesoftware.com> schreef:
"Re: 5 days a week"
To view the discussion, visit: http://community.qlik.com/message/166618#166618
I believe you could add a check for weekday (Mon=0 to Sun=6) then:
=sum({<Date= {"=weekday(Date)<5 and Date < firstworkdate(today(),2) "}>} Value)
or
=sum(if( weekday(Date)<5 and Date < firstworkdate(today(),2), Value))
to sum all workdays value up to 2 workdays (excluding) prior today.
Alternatively, you could add a workday flag to the data model (use if(weekday(Date)<5,1,0) as WorkDay), then could use something like
sum( Value*WorkDay )
to sum all values only on workdays.
Hope this helps,
Stefan
edit: Since we are already limiting the weekdays, you maybe don't need the firstworkdate() anymore or a simple today()-2 might also do. I admit I haven't fully understood your full requirement at this point.
Stefan,
Thanks, i will try tomorrow something with Weekday.
I will let know you if the problem is solved.
Maybe you have idea about this problem can solved in the
guide card "settings".
Kind regards,
Gerrit
The Netherlands
-
swuehl <qliktech@sgaur.hosted.jivesoftware.com> schreef:
"Re: 5 days a week"
To view the discussion, visit: http://community.qlik.com/message/166625#166625
Do you mean the settings menu within the QV application, like document settings? I don't think that there is a global setting to only consider weekdays in calculation, or do I misunderstand something?
Stefan,
I mean where you can type things like this:
SET ThousandSep='.'; |
SET DecimalSep=','; |
SET MoneyThousandSep='.'; |
SET MoneyDecimalSep=','; |
SET MoneyFormat='$#,##0,00;($#,##0,00)'; |
SET TimeFormat='h:mm:ss TT'; |
SET DateFormat='DD/MM/YYYY'; |
SET TimestampFormat='DD/MM/YYYY'; |
SET MonthNames='Jan;Feb;Mrt;Apr;Mei;Jun;Jul;Aug;Sep;Okt;Nov;Dec'; |
SET DayNames='Maa;Din;Woe;Don;Vry;Zat;Zon'; |
Let vYearAdj = Year(Today()) - 2010; |
LET numMonth = 12 * $(vYearAdj); |
ODBC CONNECT TO VRE; |
Kind regards
Gerrit
Hi Gerrit,
so you are talking about the script, right?
I am not sure how familiar you are with the back end / script part of QV, but I think you could either create an additional field (maybe called IsWorkDay) like mentioned above, in the same table as your Date field:
Load
...
if(weekday(Date)<5,1,0) as IsWorkDay,
...
from ...
Another way would be to use variables to abstract the Workday part of your expression, and you can define these variables either in the script (using LET) or in the variable overview dialog in the front end. But first check that you get your results using the above expressions or after your modifications.
Regards,
Stefan
Stefan,
With this solution i can select workdays en no workdays.
But the database have only workdaydates.
So, if i will count the arrears of hours over a weekend then the sunday en the saterday is
also count. I will create a week of five days.
Kind regards
Gerrit
-
swuehl <qliktech@sgaur.hosted.jivesoftware.com> schreef:
"Re: 5 days a week"
To view the discussion, visit: http://community.qlik.com/message/166740#166740
Gerrit,
not sure if I fully understand. You have a solution now somehow or do you still have a problem?
Maybe if you could upload a small sample, this will help me or someone else to understand and then help you with a solution. You can upload files in the advanced editor.
Regards,
Stefan