RunningCount/RunningSum Business Objects - how to reset every occurrence of blank - business-objects

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])

Related

Laravel array filtering

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.

Automatic Average For X Most Recent Column Entries

I have a sheet where someone enters numbers into a column every week
Is there a way to have a column that automatically shows the average of the x most recent weeks entered?
So when a new week is entered, the average formula automatically changes the range of columns used for that average
Or possibly via script if needed?
e.g. After the user fills in the new week, I could have them run a script in the sheet to recalculate the average.
Any hints are appreciated.
Not sure how to word a search to look for examples.
And the winner seems to be AVERAGE & OFFSET
This gives me the average for the last 5 entries in the 2nd row
=AVERAGE(OFFSET(C2,0,COUNT(C2:AQ2)-5,1,5))

Avg difference between consecutive mysql rows for specific month

I'm busy creating a personal mobile web app for home management.
Each day a READING is entered into a table, along with the days DATE.
One reading per day, meaning DATE is unique. READING could be the same, by very unlikely, if there is no usage for that day.
A usage amount for the day is calculated, by subtracting the previous days reading from the newly input reading.
How would I calculate the average usage numbers for a particular month?
Should the usage amount, once calculated, perhaps be stored back to the newly added row? Leaving for easy use of this to find an average?
Should a separate primary key be added, numbering the records, as apposed to using date to calculate the latest record added?
Thank you in advance, any help appreciated
Final solution:
When adding the latest readings, calculate day usage using previous record (found by using date). Add this to a third column.
To find daily average for current month, use MySQL avg, and limit to current year, and current month.

How can I calculate YTD values in report?

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.

Limit the times users can work with my web app

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