Resetting serial field annually in MS Access 2016 - database

After digging the net for days with no luck, I hope to find the answer here.
I have a simple ms access 2016 database and I have a table with Period as one field and Serial as a second field.
Period is a number that represents a year.
I would like to make Serial a calculated field with the following formula:
Nz(DMax("[Serial]","[Table1]","[Period] = " & Year(Date())),0) + 1
I am trying to get a result similar to:
Period | Serial
------------------
2016 | 1
2016 | 2
2016 | 3
2017 | 1
2017 | 2
2018 | 1
That is a serial number that should be reset every new year.
However, Access seems not to like DMax and it issues the following error message:
The expression .... cannot be used in a calculated column.
Is there an acceptable way to make it?

Related

Visualize attendance over time data in a meaningful way

I have data that looks like this
+-----------+-------------+----------+------------+------------+
| Date | Time | Initials | Location 1 | Location 2 |
+-----------+-------------+----------+------------+------------+
| 8/26/2019 | 11:00:00 AM | BI | 39 | 40 |
| 8/26/2019 | 1:30:00 PM | Kk | 12 | 2 |
| 8/27/2019 | 2:30:00 PM | BH | 18 | 37 |
| 8/28/2019 | 3:30:00 AM | BH | 23 | 29 |
+-----------+-------------+----------+------------+------------+
The output should be something very similar to the Google Maps "Popular Times" graph.
I would like to be able to visualize
A graph for each location in this style (attendance over time via hour), which is the average attendance per day of the week
I would also like to be able to specify a given date ex: 8/26/2019 and pull up the exact data for that date
So I figure either there can be a different graph for every location, or maybe have the various locations data show as different colored bars on the graph.
Ultimately I have this data in a spreadsheet and I'm not sure what would even be the best tool to use to report this data. I looked into data studio and google analytics and just using charts inside the sheet.
However the issue seems to be:
Since the data can be both various dates and various times. I'm not sure how or which tools to use to group the data by a given day, or average the data for a given day of the week. I tried using pivot tables but I'm not sure how to report based on that.
which tools to use to group the data by a given day, or average the data for a given day of the week
=QUERY(QUERY(A2:E,
"select A,count(A),sum(D),sum(E),sum(D)+sum(E),avg(D),avg(E),avg(D)+avg(E),max(D)+max(E),min(D)+min(E)
where A is not null
group by A", 0),
"offset 1", 0)
=QUERY(A2:E,
"select A,count(A),sum(D),sum(E),sum(D)+sum(E),avg(D),avg(E),avg(D)+avg(E),max(D)+max(E),min(D)+min(E)
where A is not null
group by A
pivot C", 0)
need to figure out how to take this input and arrange by Day of the week
=ARRAYFORMULA(IF(A2:A, TEXT(A2:A, "ddd"), ))
Also by hour instead of just by date
=ARRAYFORMULA(IF(A2:A, TEXT(TIME(HOUR(B2:B), 0, 0), "hh:mm:ss"), ))

Google Data Studio: Formula difference between first and last values within date range?

In Google Data Studio, I need to show the difference between the first value and the last value, in a selected date range (selected by a filter in the report).
Example data set:
date | total_eggs
-----------------------
2018-01-11 | 7
2018-01-12 | 7
2018-01-13 | 7
2018-01-14 | 8
2018-01-15 | 9
2018-01-16 | 10
So, I need a formula/calculated field that will show that the difference between first and latest value 'total_eggs' = 3. This means, we have gained 3 eggs over time.
This should be simple, but not finding the answer to this in relation to Google Data Studio specific implementation.
Can someone please help?
I can't find any way to do that in a table as a running difference. You could do it as a scorecard with a field as simple as
max(total_eggs)-min(total_eggs)
That would change if you change the dates.

TM1 - passing data between cubes by linking a measure in the target cube to a dimension in the source cube

TM1 - linking measures to dimensions
I have two cubes in TM1, and I am trying to source data from one cube by linking a calculated 'Age' field in the target cube to an 'Age' dimension in the source cube. However, while I can do this fine by writing code in the rules editor, I cannot work out how to do it using the rules Wizard. Unfortunately, policy in my company is that all TM1 models must be based around wizard-based rules, so I am hoping someone could explain how to do this via the wizard.
Cube 1 (the source) contains data on how quickly a loan balance reduces due to customer attrition, based on the loan's age in months - it looks a bit like this:
Age | Attrition %
-------|--------------
1 | 5%
2 | 6%
3 | 7%
Cube 2 (the target) contains a loan balance, and calculates how the balance reduces over several months, based on the data in Cube 1. It looks up the data in cube 1, based on the age that is calculated in the first row of Cube 2, on the basis of:
current month - start month + 1.
So if we assume the loan started in July, for August the age would be:
8 - 7 + 1 = 2 months old.
For the loan starting in July, Cube 2 would look a bit like this:
| Jul | Aug | Sep |
----------------|-------------------
Age | 1 | 2 | 3 |
Opening Balance | $100| $95 | $89 |
Attrition % | 5% | 6% | 7% | <-- sourced from Cube 1 on basis of Age
Attrition $ | -$5 |-$5.7|-$6.3|
Closing Balance | $95| $89 | $83 |
Creating this link is trivial in Excel, but whenever I try to do it using the TM1 Rules Wizard, I run into the problem that TM1 does not seem to allow the linking of a dimension ('Age' in cube 1) to a field within a dimension ('Age' in cube 2).
Can anyone advise?

Store Curve Data in SQL Server table

I have a SQL Server table in which I need to store daily interest rate data.
Each day, rates are published for multiple time periods. For example, a 1 day rate might be 0.12%, 180 day rate might be 0.070% and so on.
I am considering 2 options for storing the data.
One option is to create columns for date, "days" and rate:
Date | Days | Rate
=========================
11/16/2015 | 1 | 0.12
11/16/2015 | 90 | 0.12
11/16/2015 | 180 | 0.7
11/16/2015 | 365 | 0.97
The other option is to store the "days" and rate via a JSON string(or XML.)
Date | Rates
=============================================================
11/16/2015 | { {1,0.12}, {90,0.12}, {180, 0.7}, {365, 0.97} }
Data only will be imported via bulk insert; when we need to delete we'll just delete all the records and re-import; there is no need for updates. So my need is mostly to read rates for an specified date or range of dates into a .NET application for processing.
I like option 2 (JSON) - it will be easier to create objects in my application; but I also like option 1 because I have more control over the data - data types and constraints.
Any similar experience out there on what might be the best approach or does anyone care to chime in with their thoughts?
I would do option 1. MS SQL Server is a relational database, and storing key:value pairs as in option 2 is not normalized, and is not an efficient for SQL Server to deal with. If you really want option 2, I would use something other than SQL Server.

How to design a Db table for attendance

I am currently working on a school management system but can't seem to figure out the best way to design my student attendance table.
INFO
School is for 14 weeks and class holds 5 times a week. Students in the school can be up to 2000 per term. Meaning attendance can be up to 14 x 5 x 2000 = 140, 000 per term.
I am developing the application for a desktop using VB.Net and MS Access.
PROGRESS SO FAR
I have so far designed something that I am skeptic about.
table name: attendance
_____________________________________________
| id |std_id | att_week | att_date | status |
''''''''''''''''''''''''''''''''''''''''''''''
| 1 | 0001 | 1 |29/9/2015 | yes |
''''''''''''''''''''''''''''''''''''''''''''''
| 2 | 0002 | 1 |29/9/2015 | yes |
''''''''''''''''''''''''''''''''''''''''''''''
I easily found out that designing it like this can easily yield 140, 000 rows in a term.
I also thought of making the week days as column names, that will easily result in 14 x 5 = 70 columns.
What is the best way to design this said table.
Friend I think you should construct your table like this:
Table would accept only the absentees
id student_id class date
________________________________________
1 11 7a 11/11/2020
2 21 6b 10/12/2020
and so on.....
You could easily retrieve details like
1] total absentees per class
2] total absent of a student in date range
3] Per day report of attendance of student can be easily prepared based on this data
ALSO this would be extremly fast due to less number of record and if you index on class_id and and partition tables in specified date range.
Thank You!

Resources