SSAS - Creating a measure the only counts the newest events - ssas

I'm new to SSAS and I'm not sure how to heavily customize a measure.
My fact table stores every change (events like created new page or deleted page).
The default measure will return a count of all changes but I also need a measure that
will display the number of pages (to which the events refer) in the system. It should only count one event for every distinct page but using the latest status of the system as of the date being used as a filter.
For example: Somebody creates 5 pages on Monday and then deletes 2 pages on Tuesday and adds 1 page on Friday.
That's 8 events but only 6 unique pages so the measure should display 5 pages if filtered for Tuesday and 6 pages if filtered for Friday. It should only count the events that are the last one for that page (As opposed to using the first event for that page as this could affect other dimensions).
How would I go about doing this?

You already have an Event_Count Measure, and you now need to create a Page_Count measure. This Page_Count measure will have a Last_Change_Type dimension and a Time dimension. Slicing the Page_Count measure by the Last_Change_Type dimension will give you what you're after.
To create a view for your Page_Count fact, you could just group your Event_Count fact table by the Page_Id and get the MAX(Event_Date) info for all the dimensions.
This is all very conceptual without a view of your schema, but your measure doesn't sound complex, it is just not at the "Event" granularity, it is at the "Page" granularity.

Related

SSRS Bar Chart Filtering Incorrectly

I am trying to create a chart showing the 10 highest-performing teams according to their "proportion of target achieved" score.
My dataset comprises every day worked by every individual in my organisation. The data is grouped in a stored procedure by month, team, job role, area of the organisation...
My SSRS report takes this data and sums it at a report level, based on a half-dozen parameters (mainly to the above groups).
The data is presented via a table, showing (for a given person/group/category) the hours worked, actual contact time (time with clients), expected contact time (time they're meant to spend with clients), and the proportion of their target they are achieving (actual contact time / expected contact time). All of this is reported for each of the last 6 months.
I.e.
I wanted to create a bar chart showing the 10 teams with the highest proportion of target achieved values. This variable is calculated in SSRS in order to allow for the data to be more flexible.
SSRS wouldn't let me use that calculation in a chart filter, so I added a denserank (called TeamOrder) for the teams in the stored procedure.
This is where the issue arises.
TeamOrder is used in the filter, and set to <= 10. 10 teams are displayed in the graph, but not the 10 that have values of TeamOrder equal to 1-10. The top couple are right, but in 10th position, for example, it's displaying the 32nd-best team.
Weirdly, when I set the filter to TeamOrder = [value], then it displays the one (correct) team (including the correct number 10 when TeamOrder = 10).
I'm at a complete loss as to what might be happening; any help would be enormously appreciated.

Qlikview line chart with multiple expressions over time period dimension

I am new to Qlikview and after several failed attempts I have to ask for some guidance regarding charts in Qlikview. I want to create Line chart which will have:
One dimension – time period of one month broke down by days in it
One expression – Number of created tasks per day
Second expression – Number of closed tasks per day
Third expression – Number of open tasks per day
This is very basic example and I couldn’t find solution for this, and to be honest I think I don’t understand how I should setup my time period dimension and expression. Each time when I try to introduce more then one expression things go south. Maybe its because I have multiple dates or my dimension is wrong.
Here is my simple data:
http://pastebin.com/Lv0CFQPm
I have been reading about helper tables like Master Callendar or “Date Island” but I couldn’t grasp it. I have tried to follow guide from here: https://community.qlik.com/docs/DOC-8642 but that only worked for one date (for me at least).
How should I setup dimension and expression on my chart, so I can count the ID field if Created Date matches one from dimension and Status is appropriate?
I have personal edition so I am unable to open qwv files from other authors.
Thank you in advance, kind regards!
My solution to this would be to change from a single line per Call with associated dates to a concatenated list of Call Events with a single date each. i.e. each Call will have a creation event and a resolution event. This is how I achieve that. (I turned your data into a spreadsheet but the concept is the same for any data source.)
Calls:
LOAD Type,
Id,
Priority,
'New' as Status,
date(floor(Created)) as [Date],
time(Created) as [Time]
FROM
[Calls.xlsx]
(ooxml, embedded labels, table is Sheet1) where Created>0;
LOAD Type,
Id,
Priority,
Status,
date(floor(Resolved)) as [Date],
time(Resolved) as [Time]
FROM
[Calls.xlsx]
(ooxml, embedded labels, table is Sheet1) where Resolved>0;
Key concepts here are allowing QlikView's auto-conatenate to do it's job by making the field-names of both load statements exactly the same, including capitalisation. The second is splitting the timestamp into a Date and a time. This allows you to have a dimension of Date only and group the events for the day. (In big data sets the resource saving is also significant.) The third is creating the dummy 'New' status for each event on the day of it's creation date.
With just this data and these expressions
Created = count(if(Status='New',Id))
Resolved = count(if(Status='Resolved',Id))
and then
Created-Resolved
all with full accumulation ticked for Open (to give you a running total rather than a daily total which might go negative and look odd) you could draw this graph.
For extra completeness you could add this to the code section to fill up your dates and create the Master Calendar you spoke of. There are many other ways of achieving this
MINMAX:
load floor(num(min([Date]))) as MINTRANS,
floor(num(max([Date]))) as MAXTRANS
Resident Calls;
let zDateMin=FieldValue('MINTRANS',1);
let zDateMax=FieldValue('MAXTRANS',1);
//complete calendar
Dates:
LOAD
Date($(zDateMin) + IterNo() - 1, '$(DateFormat)') as [Date]
AUTOGENERATE 1
WHILE $(zDateMin)+IterNo()-1<= $(zDateMax);
Then you could draw this chart. Don't forget to turn Suppress Zero Values on the Presentation tab off.
But my suggestion would be to use a combo rather than line chart so that the calls per day are shown as discrete buckets (Bars) but the running total of Open calls is a line

Turning a flat SQL table into a report, aggregating numbers and nesting calculations/comparisons in a view query

I have a huge flat table containing data from a handheld device. I currently use it to generate reports for a 'site', but this is done with a homegrown PAAS. The report works great (allows you to view an individual site), but most of the calculations are done on this .net layer. I however now need to expand to include key information on ALL sites, in a summarized type of way (line by line for each 'site'). I have an element (repeating panel) that can display all of this information by cycling through a table or view, and then lead the user into the individual report (that already exists on the paas), but I need to basically create a VIEW (I think this would be best but I could be wrong?) that will hold all this summarized information to be displayed, as well as an ID (site name) so that when an item in the repeating panel is selected I can drop the user on the individual site report he requires.
so here goes nothing...
The database is being used to create reports based on security guard tags checked. We extract information such as average patrol times, tags missed on routes, alarms pressed etc from a haldheld device.
I have the following coloumns of importance in my tables:
Data Import- This table is where 'transaction' data appears. basically every data line from my device.
-Site Name
-Route ID
-Patrol ID
-Type
-Tag Name
-Occurrence Date
Route Profiles- This is a profile of the route, basically containing a full set of 'tags' for a route ID that can be checked against to see which tags were not checked in each patrol, and how 'successful' this patrol by a guard was. We dont neccessarily need to use this table to get an aggregated understanding of how many tags were checked in a patrol, but the 'TotalTags' value is used to check against.
-RouteID
-Site Name
-TotalTags
-PerfectPatrol
I am trying to obtain the following basic stats. The challenge now is to generate a view that has all the aggregated calculations row by row. Each row is to cover the previous day's 6am to 6am window (based on the occurrence date coloumn).For each site I am trying to work out the following (which will effectively sit in 1 row of this VIEW):
1. Patrols required - this is calculated by counting the number of "PATROL STARTED" occurences in the 'type' coloumn for the site in question (each row will belong to a site, and effectively summarize that site)
2. Tags in route - pulled straight from the route profile table (match route ID)
3. Average patrol time - This is calculated by measuring the difference in 'occurrence date'(datetime) for each patrol (unique patrol ID's) in when a 'PATROL STARTED' and 'PATROL FINISHED' value appear in the type coloumn. This will be aggregated, eg a patrol of 10, another of 12, and another of 14, will result in an ave patrol time of 12 (minutes).
4. Successful patrols - this is an aggregated value for the number of patrols that occurred in this time window that (percentage wise) either match or are greater than the 'perfectpatrol' coloumn in the route profile (this figure in perfectpatrol is usually 100%) divided by the number of patrols required (see 1). Basically, counting up the number of tags obtained in that unique patrol, that are greater or equal to the number of tags in that route (totaltags), over the total number of patrols required (see 1)
5. Incomplete patrol - a patrol that contained some tags (less than perfectpatrol percentage), but not none. Worth noting here, a tag can be identified by the occurrence of 'TAG COMPLETED' in the 'type' coloumn.
6. Failed patrol - when no tags are checked in a patrol (so if in a unique patrolID there are no 'TAG COMPLETED' values in the 'type' coloumn).
7. Total alarms raised - the number of times 'CALLME' 'PANIC' or 'MANDOWN' occurs in the 'type' coloumn.
8. Call Me Alarms - the number of times 'CALLME' occurs in the 'type' coloumn.
9. Panic Alarms - the number of times 'PANIC' occurs in the 'type' coloumn.
10. Man Down Alarms - the number of times 'MANDOWN' occurs in the 'type' coloumn.
Things to note:
1. there can sometimes be multiple routes per site. It would be preferrential for each route to have its own row in this case, sharing the same site name.
2. Each report is over 24 hours, from 6am to 6am, and for the previous day. So an overriding filter on the Data Import table would ensure this.
I have no idea how to approach this due to the sheer size and complexity of all of these operations existing within one huge SQL query. As was mentioned, we use an in house paas that requires little coding, hence me reaching out for advice/help.
How do I go about tackling this problem?

Clickstream measures at different granularities

This is possibly a simple problem which I have yet to overcome.
Consider a cube based on clickstream data.
First, I have a fact table based on page views. That is One Row per page view on a site. Measures includes [Views], [Visits], [Bounce Rate] etc.
Secondly I have a measure group based on Leads. Measures include [Leads], [Revenue], [Margi]n etc.
One page can create multiple leads, therefore a one to many relationship exists. OFF of this Leads Fact I also have a Leads Dimension which describe the lead. An example attribute may be [Quality] = Good / Bad.
Now when browsing the cube I might want to see the number of [Views] or [visits] against the Lead Attribute, [Quality]. The problem in a one [View] to many [Leads] is that the [Views] are incorrectly multiplied for each lead each created.
e.g. One [View] created 3 [Leads]. [views] by [quality] = 3
I want Views by Quality to be DIVIDED and = 0.33 or, ideally, still 1.
"1 View Created 2 bad and 1 Good Lead"
Would anyone have any ideas on how to solve this ?
THANK YOU !!!

Discritization Based on a Calculated Measure in Tabular Mode

I am currently trying to implement the following scenario on Tabular Mode SSAS, appreciate your support.
We have a fact table of Transactions that is the linked to the customer dimension, and we have a measure called Frequency that shows the number of times the user used his card during the selected period (The fact table is also linked to Date Dimension). What we need to do is create a dimension that would have the frequency groups as follows (For example, 1 to 5, 5 to 10 , 10 to 15 and 15 & Above). The problem here is that I am unable to link the Fact table to this dimension becuase the link between them would be a calculated measure.
Any thoughts?
Thanks and Best Regards
Omar Sultan
If you want to link the fact to a bucket dimension, you are going to have to specify the time granularity. I would suggest that you decide one or more useful periods (day, week, month) and create a facts (or several) to bucket your data at the appropriate grain.
This solution will lose flexibility from your original request, as the user will not be able to dynamically select the time period for the bucket, however they will gain from being able to compare fixed time periods to identify trends over time.