Is there another way in Qlik Sense to show the latest weeks data by default as well as a filter to change the week you're looking at? - variables

I am looking to add a weekly filter onto my Qlik dashboard to allow me to change the weekly data that is displayed on my dashboard. My original idea works well as I wanted to display the latest weeks data and compare this to the previous weeks and this gives me exactly what I want.
To enhance this and give the dashboard a bit more flexibility and just in case someone wanted to look at a different week, I thought it might be a good idea to add a weekly filter but the way I have built the dashboard won't allow me to do this. The following is an example of what I have:
In my database table I have a rank column (latest_week_rank) where the latest weekending (i.e. Mon 13th to Sun 19th Jan) has a value of 1 and the 2nd latest week would be 2 etc. I have then written the following code in my data tab:
latest_week = 1;
previous_week = 2;
I have then written the following which is then called within a Multi KPI:
vOrdersWTD =Sum({<latest_week_rank = {$(latest_week)}>} total_orders)
This is obviously where the problem lies as having the weekly filter makes no difference as no other weeks show up but I am not sure how I change my code in order to make this all work.
I would really appreciate if somebody could advise on how I can change this around.

Instead of assigning your predetermined variable in set analysis, use the actual field. Something like:
$(=
'Sum({<latest_week_rank = {'
& max(latest_week_rank)+1
& '}>} total_orders'
)

Related

Excel Forumla/VBA to skip blank columns for calculation

I have a particular data set that consists of information for projects our company works on. Each project can go through five different statuses and we have a column that records each date the project is put into that particular status.
Now for the Excel part. We are trying to calculate the days in each status and find the total project time. The total is easy to do, because I can use network days between the project submitted date and the project go live date. The statuses, however, are giving me issues because sometimes a project will skip a status, leaving the date field empty. So what happens is a project goes from status B to status D, the formula for days in status "B" look for a date in column "C" to use as the second date in a NETWORKDAYS formula. When it is empty, the IF argument tells the formula to use TODAY() as the second date. What I need it to do is the search the columns to the right (within the given range of A:E for that row) and use that date if it exists. If not, then it can default to TODAY() because this would be an "active" project that has not moved on.
=IF(IF(OR([#STALLED]<>"",[#CANCELED]<>""),"",IF([#INTAKEDATE]="","",IF([#SCOPEATE]="",NETWORKDAYS([#INTAKEDATE],TODAY()),(NETWORKDAYS([#STATUSADATE],[#SCOPEATE])))))<0,"",(IF(OR([#STALLED]<>"",[#CANCELED]<>""),"",IF([#INTAKEDATE]="","",IF([#SCOPEATE]="",NETWORKDAYS([#INTAKEDATE],TODAY()),(NETWORKDAYS([#STATUSADATE],[#SCOPEATE])))))))
This is done for each of the statuses so the table looks something like this:
PROJECTID PROJECTNAME INTAKEDATE SCOPEATE BUILDDATE TESTDATE GOLIVEDATE INTAKEDAYS SCOPEDAYS BUILDDAYS TESTDAYS
If there is any Macro or better formula someone could help me figure out, I'd appreciate it. There is also another field that gives the current status or if the project is considered live if that helps at all. I have excel-block right now and cant think of anything that makes sense for this.
So I figured it out using MIN and by adjusting the IF formulas a bit. Whoever it was that posted about MAX earlier, really helped me out getting me down this path. Kudos to you sir/madam.
I had to add the check to see if SCOPEDATE=BUILDDATE because without that it was returning 1 if the dates matched, with was adding one more day when compared to running the networkdays from INTAKEDATE to GOLIVEDATE.
=IF(OR([#STALLED]<>"",[#CANCELED]<>""),"",
IF([#SCOPEDATE]="","",
IF([#SCOPEDATE]=[#BUILDDATE],0,
IF(NETWORKDAYS([#SCOPEDATE],(MIN([#BUILDDATE],[#TESTDATE],[#GOLIVEDATE])))<0,NETWORKDAYS([#SCOPEDATE],TODAY()),NETWORKDAYS([#SCOPEDATE],(MIN([#BUILDDATE],[#TESTDATE],[#GOLIVEDATE])))))))
I hope this is helpful for someone else.

How do you get the ticket created date in trac?

I want to play with some really simple queries for a report, but I want to group everything by the creation date. The problem I am having is that time exists in the database, but not the date. From searching around in trac-related resources, it looks like I need to install trac.util.datefmt to be able to extract this information from datetime(time). I can find the API documentation for trac.util.datefmt, but not a download link to get the .egg.
Am I going in the right direction? If I can do what I need (i.e. get the creation month/day/year) without a plugin, what column do I use? I don't see anything else in the schema that is reasonable. If I do need trac.util.datefmt, where do I download it from? And if I really need a different plugin, which one should I be using?
I'll assume Trac >= 1.0. The time column is unix epoch time: the number of seconds that have elapsed since January 1st 1970. You can divide the value by 1e6 and put the value in a converter to see an example of extracting the datetime from the time column. trac.util.datefmt is part of the egg that ships with Trac, but since you are working with reports it doesn't sound like you need to know more about that function to accomplish your aim.
In a Trac report the time column will be automatically formatted as a date. You can look at the default report {1} as an example. I'm not sure how you intend to group by creation date. Do you wish to group tickets created in a certain datetime range?

Excel - VBA - Access: Date Selection Solution

I'm looking for a direction, assuming that surely someone has had to do something similar and I'm making this more difficult than it is.
We have an Access DB, feeds to a pivot table in Excel, which is in turn used to supply charts for a "user dashboard." This is 2010, so no slicers.
My problem is that that DB is updated adding months to a field. There is a listbox in the dashboard that will allow the user to select a specific month and see stats for that time. I'm having a couple problems even getting started and would like to make sure I'm going about this the simplist/most efficient way.
My thought was to populate the listbox with the 'month' fields from the pivot table. I'm not quite sure how I'm going to do that with VBA (I have a couple ideas), but if that's the best route then I'll figure it out.
But, has anyone had a similar need, and found a better solution? I have a bunch of buttons to handle other fields, but I would really like to allow for the user to select a date/month/range...whatever. Surely this is a common, easily managed desire, no?
I'd put this in with the conversation you're having with a couple of people above, but I don't have enough rep to do that yet.
I had a similar dashboard issue years ago. Resolved it by adding a dropdown beside the month box (which was a dropdown in my case, not a listbox) with the options "Year to date" and "Month to date". By definition selecting a past month and MTD gave you the whole month, whereas selecting the current month can only ever give you MTD. Same thing with YTD - it would give you the combined stats for the current year to date instead of just one month.
The month dropdown in my dashboard was populated based on the current data in the pivot, which in turn was controlled from the database. We used a 25-month rolling select for the data and showed only the last 13 months in the month dropdown. That gave us a full 12 month spread of historical data to work from if someone chose the oldest month we offered them, yet kept the size of the pivot cache manageable
I used a dropdown for the options instead of option buttons or a checkbox, because I had a suspicion that delivering what was asked for would lead to additional requests. I was right. Eventually we had options for "Last year to date" (how we were tracking this day last year), "Quarter to date", "Financial year to date", and so on. Adding extra choices to the dropdown box was easier than rearranging the dashboard to accommodate the proliferating requirements.

pulling current date queue

I have a view that lists employee (EmpID), request number (ReqNo), date request was opened (OpenDate) and the date it was moved to the next step in the process (AssignDate). What I am trying to do is get an average of the daily queue size. If EmpID 001 has 20 requests on 1/1/13, then has 24 on 1/2/13, 21 on 1/3/13 the average over 3 days should be 21.66, rounded up to 22. I have the following view:
CREATE VIEW EmpReqs
AS
SELECT [EmpID], [OpenDate], [AssignDate], [ReqID]
FROM [Metrics].[dbo].[Assignments]
WHERE OpenDate BETWEEN '01/01/2013' AND '12/31/2013' AND
[EmpID] IS NOT NULL AND
[ReqNo] NOT LIKE 'M%'
I then wrote a query to pull individual employee's queues per day:
/* First attempt to generate daily queue #s */
SELECT * FROM BLReqs
WHERE [BusLiaison] LIKE 'PN' AND
[OpenDate] <= '11/15/2013' AND
[AssignDate] > '11/15/2013'
Because no one has attempted to pull this information before, I have no way of verifying how accurate the above is. I tried using current dates, since I can see those in our database to compare but the code doesn't work, nothing is returned when I change the dates to 2014 and run my query.
What is the easiest way to verify that my code is correct, short of manually counting a day's queue?
Can anyone see any issues with the above scripts?
Is there a way to get the above code to work with current dates?
This question is really hard to answer because it is kind of broad and has little information at the same time. I'll try anyway:
Because no one has attempted to pull this information before, I have
no way of verifying how accurate the above is.
Try checking the result of this query for a few sampled dates.
I tried using current dates, since I can see those in our database to
compare but the code doesn't work, nothing is returned when I change
the dates to 2014 and run my query.
So clearly, the query is not working. You should probably find out why. Run the query for a date of which you know that it should return results but doesn't. Remove conditions one by one to see which one is incorrectly removing all rows. This should be enough to identify the bug.
Can anyone see any issues with the above scripts?
No, looks fine. A very simple query. That's why I said that we have too little information. There is some key piece of information missing that allows us to find the bug.
Is there a way to get the above code to work with current dates?
Stop staring at the code and hoping for a revelation. Debug it. Experiment.

SQL Filtering based on Calculated Time Slots

Im making a simple booking system for our projectors at work.
Here is the scenario. Each projectors can have its availability set to quarter hour segments throughout the entire day. i.e projector 1 is available between 8:15am - 1:45pm and 3pm-5:15pm each day (can also be changed to have different availabilities set for each day). A projector can be booked for anytime time segment during the day as long as it is available. So ive got that setup in my sql database (with my asp.net mvc front end).
The question i have is what is the best way to search on this scenario. i.e. UserA comes in and says find me the projectors that are available this friday between 12pm-3pm. Im struggling to write an efficient sql query that will filter this. My best option so far is to pull back all projectors and than programatically work out if they are available and not booked between this time. It works but it is incredibly inefficient. I stumbled an idea of using a temp table generated by a stored proc that can than be filtered but it isnt quite there.
Has anyone got any ideas how i could approach this?
Thanks in advance
I would probably have a table called ProjectorReservations which contained a start time and end time (amongst other fields you might care about i.e. who is renting the projector).
Searching a projector would look something like this:
SELECT projectorName
FROM Projectors
WHERE NOT EXISTS
(SELECT 1 FROM ProjectorReservations
WHERE Projectors.projectorName = ProjectorReservations.projectorName
AND (ProjectorReservations.startTime < {end_time}
OR ProjectorReservations.endTime > {start_time}))
That pretty much checks to make sure no reservations start before the one you are looking for ends and vice versa. Obviously you will need to swap in your fields accordingly but that should give you the general idea