I have a simple web app and I would like to limit the times the user can use my app.
Basicly my app generate some report, so I should count how many report they generated in a month.
I was thinking to create a database table where I store the month and the times count of generated report. Each time user generate a report the script check the month to see if is current month and if is current month it increase the times count. Instead if the current month is different it sets the times count to 0.
Is this a good start point? or i should make something better?
If it is current month and if is current month it increase the times count. Instead if the current month is different it sets the times count to 0.
You will miss out on the edge case when a user generates reports after a period of approx 1 year. Say he generates 5 times report in October 2012 , and next tries to generate a report in October 2013, then his counter starts from 5 instead of 0 in the current scenario.
I am assuming you are taking two fields to store the information currently (one field for month, the other for count).
So now, Including the year, you will need 3 fields.
To optimise on number of fields, you can instead save the date for the 1st day of current month (2 fields total).
To further reduce the number of fields, you can save the information in one field - save an integer, say yymmxx, where yy is the year, mm is the month, and xx is the number of attempts.
In this approach, to find out previous number of attempts, you will need to do field % 100, and to match if the current month is same, you will need to check for field/100 == yy*100 + mm
Related
I have a table in Business Objects in which I have created a monthly date spine and I can see how many items a customer bought in a monthly period. What I am trying to do is count the number of months in which no purchases were made and then find the longest gap across the whole date range.
Here is a mock-up in Excel of what I have got so far in Business Objects:
As you can see I have a running count, but it continues counting every time a blank row is encountered. What I want is that the counting would reset every time a new blank entry is found. I could then find the maximum gap across the date range.
What it should look like is:
The formula I have at present is:
=RunningSum(IsNull([monthly_purchase]);([monthly_purchase];[date]))
How can I adapt this to get the result I want?
Is there a reason you need the running count of months? Or is the main objective to determine the maximum number of months in a row with no purchases?
Prior Month with Purchases = Previous([MonthEnd])
Months Between with No Purchase =If Not(IsNull([Prior Month with Purchases])) Then MonthsBetween([Prior Month with Purchases];[MonthEnd]) -1 Else 0
Maximum Gap With No Purchase =Max([Months Between With No Purchase])
Developers, I am working on a report that I have to display the companies ranking based on some conditions for the date range which comes from front. Ex: last week, I have done that, but now I want to show how many weeks that a particular company be in same rank. If I am checking the past week I have to check the ranking for each week from the year start. If last week first position company and other weeks first position company is same I have make the count as increasing accordingly. When I querying the data for each week using the for loop it is taking around 42s to process and display the data. Also I tried to fetch whole data from first week of the year to current week then I filtered the array but this also takes long time. Can anyone give any other ideas to overcome this? Thanks in advance.
As far as I understand your problem - then storage of aggregated data should help you.
Create a table in the database, let's say "archive_rating", with 3 fields: week_number (let from January 1, 2000), company_id, company_position in your rating. Don't forget the index for the week_number field.
At 00:00:00 every Monday, run a background task that will save the positions for each company to an archive table.
This will allow you not to calculate a rating for each week from the beginning of the year. You will already have it.
First - thanks for your time. My issue lies in my new usage of Access for tracking values from weekly excel reports. Each week I'm given a new excel file with updated values for about 50 employees. These values generally track their performance over 6 different metrics. I've begun to link these excels into an access database to keep and track that data each week. These linked tables are given the name convention of the date that the data is as of - example: 05-05; 05-12; 05-19, 05-26; etc.
My question is - is there a way to build a query to track the change (difference in values) from last week to this week (05-19 to 05-26), automatically? And also taking into account future additions of linked tables so that I don't have to add a piece to the query each week?
In addition, I'm looking to track overall change - first table 05-05 to the most recent linked table (which ever date that's true for, whether it's the end of July, or the end of the year).
Based on these 2 results, I'd eventually build out the query to show every week with their value and in the next column the week over week change (up down or neutral)
I am working on an SSRS report that gets its data from an OLAP cube. In the OLAP cube I have a field named WeekOfYear which gives me the week number of the year based on the date. For example, week 1 for January 1st (if January 1st falls on a Monday) and week 2 for January 8th. My data is grouped by this field but now I want to be able to compare the data from this week of the year to the previous year's week of the year. Like comparing Week 1 of 2015 to Week 1 of 2014. Is there anyway that I can accomplish this? I appreciate any help. Thanks.
There is a LookUp function that should be able to do what you need.
You mention you have a WeekOfYear field. This also assumes you have a Year field (or can calculate it with **YEAR(Fields!YouDateField.Value) )
=LookUp(Fields!YourYearField.Value - 1 & "|" & Fields!WeekOfYear.Value, Fields!YourYearField.Value & "|" & Fields!WeekOfYear.Value, Fields!YourValueField.Value, "YourDataSet")
If you are actually summing multiple rows of data from your cube, you would need to use LookUpSet to get all the values and sum them with a custom function (since Microsoft couldn't possibly envision users wanting to SUM multiple records). Luckily users have already created a function - SumLookup. See How to combine aggregates within a group with aggregates across groups within SSRS if needed.
If you have access to the OLAP cube and can edit this, you could define a new Calculated Measure on the cube. How exactly this would work depends on the set up of your date hierarchies. You can also access this and define calculated measures through the Query Designer while constructing your dataset in Report Builder/Visual Studio.
Right-click in the cube browser and choose "New Calculated Member".
Reporting on weeks across years can be difficult due to the fact that the number 7 doesn't fit neatly into 365 or 366, so you always end up with a little over 52 weeks. Since the 1st of January could be a Sunday one year, and a Tuesday on the next (2012/2013), it's not always a good idea to directly compare these. So people may work around this by defining the 7-day weeks for the year against their date dimension. One year you may have 52 weeks, another you'd have 53. This is a little off topic, so I'll link to an explanation of this here, but it is important to be aware of this in order to implement my suggestion below.
Assuming you have a nice hierarchy on your date dimension that can aggregate up Weeks to Year level, you can create a new measure in your cube using the ParallelPeriod function.
[Measures].[SalesSPLY] AS
(
ParallelPeriod
(
[Dim Date].[ReportingCalendar].[ReportingYear],
1,
[Dim Date].[ReportingCalendar].CurrentMember
),
[Measures].[Sales]
)
My example MDX assumes that you already have a hierarchy called ReportingCalendar created on your date dimension. Yours may be named differently.
Now if you browse your cube and select WeekOfYear, Sales, and SalesSPLY, you will see your value for this year's week 1, alongside last year's.
OLAP cubes are very good at this type of time-based intelligence, as they can very quickly provide aggregated and offset data in a way that would be slower to run in an RDBMS or within SSRS itself.
My client has a standard report which shows monthly figures for various sales, enquiries etc. The report shows all months since the start of the contract (about three years ago, but growing by 1 every month!). The last row in the Tablix shows the totals (essentially the sum of all cells in that column above).
They have asked me to introduce another couple of rows, showing Year To Date values, for totals and monthly averages. I feel sure that there must be a way to do this simply (essentially it is the SUM or AVG of the last 12 rows in the Tablix), probably through grouping, but I just can't get my head around it.