ACCESS DSUM For a Running Total - database

I am trying to use the DSUM function to get a Running Sum of Payments made by customers. I am looking at payment history across 45 months. I have an ID column that has a unique Number customer id + the month number /(45 +1). Therefore, every customer has a unique number in between its customer number and its customer number plus 1 that associates with the payment month.
I am trying to get a DSUM so it sums every ID that is equal to the the current month ID and greater than the Customer Number.
I can get it so that it can get a running sum across all customers if I ascend the customer numbers; however, I want the total to restart at every customer. Can you tell me what I need to adjust in my formula?
CFRef is the column of Customer month reference in the Ordered CF table. Monthpmt is the sum field in the CF table.
cfr is the relative Customer Month field I have in the current query table that I am trying to match to.
PmtTot: DSum("Monthpmt","TestOrderedCF","CFRef<=" & [cfr] And "CFRef>=" & [CustNum] And "CFRef=" & [CFref])

Concatenation is wrong. Why would CFRef be compared to cfr and CustNum? Perhaps you mean:
PmtTot: DSum("Monthpmt", "TestOrderedCF", "cfr<=" & [cfr] & " AND CustNum=" & [CustNum] & " And CFRef=" & [CFref])
If fields are text type, then need apostrophe delimiters: " AND CustNum='" & [CustNum] & "' AND
Probably also need to take into account the year as well as month.
Instead of DSum(), might be able to get desired output by using report Sorting & Grouping and textbox RunningSum property.

Related

Excel, counting within a formulatext on array

Imagine rows A2:A11 = name of customer, Columns B1:AE1 = days of the month.
To make it easy:
Daily, we tally if customers purchase (quantity) and separate them with a + to get the total of that day purchase. (example: on 2nd day of the month (C2:C5)
Abe =44+54+10
John =22+10+40
Sara =40
Mary=10+10
Also we need to count total “sales cases” of the whole day (in the above example it is 3+3+1+2)= 9 to show in the last row of the day. (B12 in this example)
The logic is something like
=SUMPRODUCT(LEN(FORMULATEXT(C2:C5))-LEN(SUBSTITUTE(FORMULATEXT(C2:C5),"+","")))
But I’m getting NA.
reminder: when there are no "+" signs & the value is more than zero, it should count as 1.
help?
There is a trick to do this, which might end up a bit convoluted to achieve the end result you want
First, define a new name in Name Manager (in the Formula menu bar)
Name: FormulaText
Refers to: =GET.CELL(6,OFFSET(INDIRECT("RC",FALSE),0,-1))
Now if you have a formula in cell B3 of =10+20+30 enter =FormulaText in cell C3 and you will get the text version of the formula
You can now count + symbols in that formula using =LEN(C3)-LEN(SUBSTITUTE(C3,"+",""))
In your specific circumstances, I would offset all of this to the right of your spreadsheet, say by 35 columns, in which case you will need to change the definition of FormulaText accordingly.
A fair bit of set-up work, but the result should work automagically.

Google Data Studio date aggregation - average number of daily users over time

This should be simple so I think I am missing it. I have a simple line chart that shows Users per day over 28 days (X axis is date, Y axis is number of users). I am using hard-coded 28 days here just to get it to work.
I want to add a scorecard for average daily users over the 28 day time frame. I tried to use a calculated field AVG(Users) but this shows an error for re-aggregating an aggregated value. Then I tried Users/28, but the result oddly is the value of Users for today. The division seems to be completely ignored.
What is the best way to show average number of daily users over a time frame? Average daily users over 10 days, 20 day, etc.
Try to create a new metric that counts the dates eg
Count of Date = COUNT(Date) or
Count of Date = COUNT_DISTINCT(Date) in case you have duplicated dates
Then create another metric for average users
Users AVG = (Users / Count of Date)
The average depends on the timeframe you have selected. If you are selecting the last 28 days the average is for those 28 days (dates), if you filter 20 days the average is for those 20 days etc.
Hope that helps.
I have been able to do this in an extremely crude and ugly manner using Google Sheets as a means to do the calculation and serve as a data source for Data studio.
This may be useful for other people trying to do the same thing. This assumes you know how to work with GA data in Sheets and are starting with a Report Configuration. There must be a better way.
Example for Average Number of Daily Users over the last 7 days:
Edit the Report Configuration fields:
Report Name: create one report per day, in this case 7 reports. Name them (for example) Users-1 through Users-7. These are your Row 2 values. You'll have 7 columns, with the first report name in column B.
Start Date and End Date: use TODAY()-X where X is the number of days previous to define the start and end dates for each report. Each report will contain the user count for one day. Report Users-1 will use TODAY()-1 for start and end, etc.
Metrics: enter the metrics e.g. ga:users and ga:new users
Create the reports
Use 'Run reports' to have the result sheets created and populated.
Create a sheet for an interim data set you will use as the basis for the average calculation. The first column is date, the remaining columns are for the metrics, in this case Users and New Users.
Populate the interim data set with the dates and values. You will reference the Report Configuration to get the dates, and you will pull the metrics from each of the individual reports. At this stage you have a sheet with date in first columns and values in subsequent columns with a row for each day's values. Be sure to use a header.
Finally, create a sheet that averages the values in the interim data set. This sheet will have a column for each metric, with one value per column. The one value is calculated from the series in the interim data set, for example =AVG(interim_sheet_reference:range) or any other calculation you'd like to do.
At last, you can use Data Studio to connect to this data source and use the values. For counts of users such as this example, you would use Sum as the aggregation field type when you are creating the data source.
It's super ugly but it works.

Sum of one field minus sum of another SSRS Expression

I have a SSRS report I'm working on. What I would like to do is get the value of one field from its own dataset and subtract the value of another field from a different dataset. I can do this; however, the values are grouped so rather than giving me an individual value it gives me: (sum of all completed) - (sum of all completed the previous year).
Here is my expression I am using for the column "Compared to last year"
=SUM(Fields!Completed.Value, "MTDSales") - SUM(Fields!Completed.Value, "MTDminus1")
"MTDSales" and "MTDMinus1" are 2 seperate datasets. MTDSales Dataset is the current months sales outcomes grouped by company MTDMinus1 dataset is last years figure for this current month as i am comparing the 2 months separately.
I had to do this in a report where I was pulling current data from one database and older data from a data warehouse and combining. You will need to do a few things:
1. Establish a match field
This can be as simple as a single column. If you need to match on multiple fields you will need to add a calculated field to each dataset that you can match on. Assuming you need to match on company and financial year and each dataset returns one year of data, this might look something like match_id (assuming numeric values - otherwise you might need to use | or something as a separator):
`="A" & Fields!fin_year.Value & "B" & Fields!cust_id.Value`
2. Retrieve the data to the source field.
In your tablix add a column as you have to hold the looked up value:
=Lookup(Fields!matchId.Value, Fields!matchId.Value, Fields!Completed.Value, "MTDminus1")
3. Use the data
Now you can aggregate the data or do whatever further calculations you wish as if the field was part of your original dataset.

Getting Max and Min Values in Crystal Report Formula

I am Using Crystal Report with VS 2012 with Dataset and Populating the Report with Run Time.
I am getting Repetitive rows for My Report, It is because the Data is Entered with Different Period (Month/Year) like the salary of Person for Month and Year.
So What I thought to get rid of the Repetition of rows is I am going to Get the Values of Summarized (Group footer) portion of a Particular Employee instead of GETTING DETAIL SECTION where Every record repeats instead of Period. I have achieved it, But the Problem is the Minimum Function is not getting the accurate Minimum Period as Shown the picture.
The formula for I which I used to Show Minimum and Maximum period values is:
Maximum ({DataTable1.Period}, {DataTable1.PPO_NO})&" - "& Minimum ({DataTable1.Period}, {DataTable1.PPO_NO})
and My Formula for getting Employee Month and Year are:
SELECT PPONO, Name, Father_Name,Designation,BPS,Claimant,Age,Type,IOT, TblPPOBook.Pay_Month + '/' + CAST(TblPPOBook.Pay_Year AS nvarchar(4)) AS Period, Pension, Allow etc. From EmployeeTable Where PayDate Between Date1 ANd Date2.
The Early help in this regard will be highly appreciated.
Create a formula to convert string to date i.e
#String to date:= Datevar Date_Period:=CDate({Period});
Second use this formula to find min and max date i.e
Maximum ({#String to date}, {PPO No#})& " to " & Minimum ({#String to date}, {PPO No#}) ;

EXCEL Formula to return a SUM for a different date range (in ROW) and a different product (in COLUMN)

I have a spreadsheet of product sales by day. There are thousands of Products that were updated on different days. Each Product is in a separate column (designated by a Product ID). Each row is a different day.
I am looking for a formula that will sum the sales for each product since the day it was updated.
So there are 2 moving parts for the formula, identifying which column to sum by the product ID, and then sum from the date it was updated onwards. I have been able to isolate the Date row using
*=MATCH(F159,Sheet!A:A,0)*
and the Column reference using
*=SUBSTITUTE(ADDRESS(1,K159,4,1,),"1","")*
but I haven't been able to incorporate these into a formula that will then sum.
Any help would be grreatly appreciated, thanks!
It's probably easiest to do with a SUMIF formula, so assuming you have a specific product in column H then you can use this formula to sum for that product for sales on and after a specific date
=SUMIF(A:A,">="&Y2,H:H)
where your reference date is in Y2
Now you want the product to be dynamic too so with a specific product in Z2 you can expand that SUMIF like this to get the sum column dynamically
=SUMIF(A:A,">="&Y2,INDEX(B:X,0,MATCH(Z2,B$1:X$1,0)))
so that will find the correct column to sum, assuming product data in columns B to X (expand as required) with product name in row 1
Making a few assumptions as to your variable formats, try this:
Sub Macro1()
row = MATCH(F159,Sheet!A:A,0)
col = SUBSTITUTE(ADDRESS(1,K159,4,1,),"1","")
lastrow = Range(col).End(xlDown).Row
Set rng = Range(col & Row & ":" & col & lastrow)
Range("B1").Value = Excel.WorksheetFunction.Sum(rng)
End Sub
Did you try PivotTables in Excel?

Resources