MS Access Date Grouping is not working in report - ms-access

I have created a simple Microsoft Access 2007 app of receiving and paying vouchers, everything is working properly but one thing that my mind doesn't solve.
I have created a report template of "Receiving Amount" where I want report be grouped in respect of receiving date. I have added a field named "Receiving Date" in "Group, Sort and Total" and when I generate it, it doesn't group the content in respect of date.

Adjust your Grouping and Sorting to use the expression:
Fix([Receiving Date])

I found the solution.
The reason of not grouping date wise because Access could not understand the date, like Gustav said, format is just for display but actual value is different and Sergey S said "If the field with date contains time. you won't be able to group the report".
Finally, I had to remove time from the date and keep it clear to Access so it can group my report.
=MonthName(DatePart("m",[receiving date])) & " " & Format$([receiving date],"d"", ""yyyy")
Where receiving date is the field name.

Related

Microsoft Report Builder - Need to convert Charge Posted Period to previous month

I am new to Report Builder and do not have all of the fields that I usually would have. I have a report that the filter currently is set to Charge Posted Period = 7 and Charge Posted Period = 2021. I need to find a way to convert the Charge Posted Period to look to the last period/month so I can schedule the report to run. I have tried multiple queries and functions which did not work. enter image description here
Has anyone worked with this report builder and can guide me to correct this filter?
Note: The field Charge Posted Period is not a Date type field, I believe it is an aggregate type field.
I would make the query for the Period parameter to be based on the year selected. Then your drop-down would only contain periods in that year.
SELECT [Charge Posted Period] AS AVAILABLE_VALUES,
MAX([Charge Posted Period])OVER() AS DEFAULT_VALUES
FROM TABLE
WHERE [Charge Posted Year] = #ChargePostedYear

Access Textbox control source outside current report

I am creating a Report in MS Access 2016. I want textboxes showing a summary of data from other tables - without actually showing rows of those tables (no subreports if possible). For example, I have tried to create a textbox with formula
=Format(Avg([WeekData].[DIFOT]),"##0.0%") & " DIFOT This Week"
which should return something like
100% DIFOT This Week
(NB Weekdata is a query and DIFOT is a field in that query, all in the same database as this report.)
However instead it just gives me #Error.
Please can you tell me the most efficient way to pull together summary figures such as these without creating any more queries and/or subreports than absolutely necessary? I'm quite new to SQL and Access on the whole.
Many thanks in advance.
Use DAvg() domain aggregate function. Also, the ## characters in Format() pattern serve no purpose.
=Format(DAvg("DIFOT", "WeekData"), "0.0%") & " DIFOT This Week"
or
=Format(DAvg("DIFOT", "WeekData"), "Percent") & " DIFOT This Week"

MDX Query in SSRS Shared DataSet giving wrong Datatype

I have a shared dataset for a Mobile Report on SSRS 2016. The dataset sits on a SSAS data source, and has an MDX query to pull from the cube.
The primary key pulled back from the query is a date, and is formatted as such in SSAS; however when I use the dataset in Mobile Report Publisher it doesn't acknowledge it as a date datatype, it thinks it's a string. This means I can't use the dataset as a main series for a time chart, as it doesn't think there's anything formatted as a date.
The below is the section of MDX that I think is causing the issue.
SELECT
{
[Unresolved], [Assigned to Provider], [Unresolved past due date], [Other past due date], [Provider past due date],
[Company past due date], [Provider PDD Daily Change], [Company PDD Daily Change], [Other PDD Daily Change], [Company pre due date], [Company PRDD Daily Change]
} ON COLUMNS,
NONEMPTY(
{
[Date Snapshot].[Date].[Date]
}) ON ROWS
FROM [Source]
WHERE
( FILTER([Date Snapshot].[YQMD].[Date], [Date Snapshot].[YQMD].CURRENTMEMBER.MEMBER_KEY >= '2015-08-15') )
Update: since SQL Server 2016 SP1 the workaround explained below is no longer necessary and dates should be properly recognized without doing anything special:
To try this new functionality out, create a simple MDX query using the Query Designer that includes a date field from your data model. When you consume that shared dataset with Mobile Report Publisher, it will properly recognize the date field from your query without an additional calculated measure being required.
The original text of the answer follows:
The reason as to why this happens is explained in the official Microsoft documentation:
The default return type for Analysis Services queries is a string.
When you build a dataset in Reporting Services Report Builder, the
string type is respected and gets saved to the server.
However, when the JSON table renderer processes the dataset, it reads
the value of the column as a string and renders strings. Then when SQL
Server Mobile Report Publisher fetches the table, it also only sees
strings.
The official workaround is also explained there:
The workaround for this is to add a calculated member when you're
creating a shared dataset in Report Builder.
An example of such a calculated member (taken from here):
cdate(format([Date].[Date].CURRENTMEMBER.MEMBER_VALUE, "yyyy-MM-dd"))
But this workaround (as pointed out by Victor_Rocca in a comment to the official Microsoft documentation) has a big problem:
The downside to this is that it will return all the dates that have
been selected in your query, not just the ones that have a value
associated with it in your cube (essentially removing the NON EMPTY
behavior from the MDX query). When looking at a lot of records across
time, this could significantly impact your report performance.
So I think there's a better workaround which is creating a calculated field in the dataset:
with an expression such as this one (assuming the name of your field is 'Date' and that it returns unique names such as [Date Snapshot].[Date].[Date].&[2010-01-01T00:00:00] and [Date Snapshot].[Date].[Date].&[2010-12-31T00:00:00]:
=CDate(mid(Fields!Date("UniqueName"),33,10))
This way you don't have to manually edit your MDX and NON EMPTY behavior is preserved. This new field gets correctly identified as date datatype in Mobile Report Publisher:
In any case, help is on the way, according to this post based on information obtained at last Pass Summit (October 2016), the following is being developed:
Better support for generated MDX. The current date workaround will no
longer be needed and make everyone’s life easier.
As far as I understand - MDX query language does not contain the data type "Date", hence it will be converted to "String".
IBM support - MDX Data types
Wikipedia - MDX Data types
I had the same problem. You can go around this by creating a Member on the MDX query level using VBA functions:
WITH
MEMBER [Date] AS Cdate([Date Snapshot].[Date].CURRENTMEMBER.Name)
SELECT ...
Your snapshot date needs to have one of the suggested formats. If it does cdate() function should do the trick. SSRS Mobile Publisher will recognize it as a date instead of string.
I've encountered this before and in the tablix cell where I use one of these dates I used the following expression:
=format(cdate(Fields!Calendar_Day.Value),"dd MMM yy")
I ended up wrapping the MDX in a T-SQL query, using OPENQUERY. This is clunky as hell, especially when I needed to pass a parameter, but it allowed me to explicitly convert the result set to whatever datatype I wanted. Urgh.
The only way I managed to get MRP to recognize my date as a real date to filter trough time navigator was adding a calculated measure based on the MemberValue of the Date Dimension.
E.g.:
WITH MEMBER [Measures].[Date2] AS ([_Reference Period].[Date].CurrentMember.MemberValue)
And after that, adding the field [Measures].[Date2] to the measures of the query:
SELECT NON EMPTY { [Measures].[Date2] } ON COLUMNS, NON EMPTY { ([_ReferencePeriod].[Date].[Date].ALLMEMBERS * [Companies].[Company].[Company].ALLMEMBERS * [Contract].[Type].[Type].ALLMEMBERS * [Employee].[Gender].[Gender].ALLMEMBERS * [Situation Type].[Situation Type].[Situation Type].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_VALUE, MEMBER_UNIQUE_NAME ON ROWS FROM [SOURCE] CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

Exporting Data with a Specific Date

Scenario:
I have a single table in access 2007 with few columns and several thousand records which I have imported form a CSV file via a “DoCmd” statement.
What I want:
I want to export these records but on a basis of specific field content and with another column’s date basis. i.e. I want to export the records with the “EQ” ( content of a columns field “SERIES”) and with a date which is one amongst the many dates the column have.
The “SERIES”, I have defined in “Criteria” in my query and it is working fine as the “SERIES” remains the same every day.
Issues:
The problem is with the date that changes every month and I cannot define or hard-code it in anywhere.
Query is working fine with the file where there is no date, but with a date, it is an issue.
Question:
Can we put a user define textbox, where user can define the date and that date will be taken by the query and will return the records with that defined date? In addition, “SERIES” is already defined in query so the result will be exact.
I use the following statement for exporting the data:
DoCmd.TransferText acExportDelim, "NewFnoSpec", "fnoquery",
"C:\Users\welcome\Desktop\Output.txt", True
Using the following 'WHERE' clause as a starting point to select records for one specific date:
WHERE (((Table1.SERIES)="First") AND ((Table1.MyDate)=#4/4/2014#));
You can prompt the user to enter a date by using:
WHERE (((Table1.SERIES)="First") AND ((Table1.MyDate)=[Enter Date]));
If there was some pattern or rule as to the desired date (i.e. first day of prior month, first Monday of prior month, etc.) you could structure the 'WHERE' clause to handle that without a prompt.
Thank you for your reply and an answer. Your answer is quite helpful. I have tried a little easier way and it worked for me. I put a text box named txtexpdate, on the form and in the query ( design mode ), in criteria I have put this :
Like "" & [Forms]![Futures]![txtexpdate] & ""
This is working fine at this juncture. And thank you once again for your efforts to answer my question. Hope this also will help others as an option to this problem.
Regards
Achal

Using query parameter in Access report

I have a very basic access database where a query returns the sales
made within a set start date and a set end date.
The dates are set with two pop up boxes for the user to enter, first
the start date, and then the end date.
I have a report running off the back of this.
How can I (using VBA) get at these dates then display them on the
report - ie. the report says "Sales for Period:" and then shows the
"from date" and the "to date" that the user input.
You may find this tutorial helpful. It shows how to use a form to capture parameters for queries and reports and access the parameter values in VBA.