MSACCESS Report - Show or Hide "Group By Header" - ms-access

Goal - The report has calculated fields in the HEADER of the GROUP on Reinsurer
The goal is to only print this header when there is MORE THAN ONE "Issuing_Dealer_Name"
In the data, Corinne has 2 dealers. Therefore I want to print the HEADER of the GROUP on Reinsurer
Adam has 1 dealer. Therefore, don't print the Header of the Group on Reinsurer
Therefore, what code goes into the "On Format" event of this header?
Here's a link to a jpg of the data -
View the Dataset

The two suggestions above solved it. Thanks!
I resolved this by creating a make-table query with a select distinct clause. Then I referenced this new table in the DCount function. It works. Once I have time, I'd rather use an array to minimize report creation resources used. BTW, I created a table vs. query since the DCount would be called about 600 times.

Related

How to get a value of cell based on condition from 2nd group in same tablix in RDLC report

I am working with RDLC report, where I have a very specific customer requirement to print a summary at the end of Report.
Please refer to image below for clear understanding:
Report summary is generated based on two Groups: Resource (No), and Task Wage Type.
1st tablix group = No.
2nd tablix group = Task Wage Type.
I need to generate an average per resource where:
Average = Total Cost / Quantity (where Task Wage Type = Hourly Task Wage)
So, I am working on extracting the value for Quantity where Task Wage Type = Hourly Task Wage and show it in Total Column for each group.
How can I achieve this?
Currently I have written this expression to achieve results, but its throwing an error as shown in picture above
=Sum(CDec(Fields!Total_Cost.Value), "Resource_No1")/Sum(IIF(UCase(Fields!WT_TaskWageType.Value)="HOURLY TASK WAGE", CDec(Fields!Quantity.Value), 1), "Resource_No1")
Finally my RDLC tablix image is shown below where I have two groups
How to resolve this error?
I can't see too much wrong with your expression so I would try to simplify things and build each part of the expression up until you get an error.
Two points though...
You should not need to specify the scope "Resource_No1" as it appears that the textbox is already within the correct scope (it's in he Resource_No1 group's rows).
Also, you appear to be adding 1 into your sum amount when the task wage type does not match your criteria. You should use 0 or nothing there instead I guess.
You could just try this to start with and then if that does not work, build up each part of the expression slowly.
=Sum(Fields!Total_Cost.Value)
/
Sum(IIF(UCase(Fields!WT_TaskWageType.Value)="HOURLY TASK WAGE",
Fields!Quantity.Value,
Nothing)
)
If you still get errors, try returning just the second part of the expression and see what you get.
I just tried this on a similar setup and it worked as expected.

How to make a table on Access using "Count" and Age Range?

I downloaded a record of all the people on the first fleet from this website. http://firstfleet.uow.edu.au/download.html
I downloaded the Excel and imported it into Access. In the document, certain people’s age is not known so they are simply put as -1.
I am trying to make this table but I am struggling.
I’ve tried doing it by creating a table but that was too hard so I decided to create a query instead. I am using “Crosstab” but failing to use it successfully.
When I do try to sub the -1 for unknown:
Messages like this pop up:
How do we add the table in but sub the -1 for unknown while keeping the layout the same? I am hard stuck at a place where I cannot even view how my query looks.
How do I even make the layout the same as the picture shown above?
UPDATE:
Calculate the age groups with Switch() function and use that calculated field for CROSSTAB RowColumn. I renamed the Age field in table from the original import name to shorten the expression.
TRANSFORM Count(Convicts.ID) AS CountOfID
SELECT Switch([Age]=-1,"Unknown",[Age]<15,"10-14",[Age]<20,"15-19",[Age]<25,"20-24",[Age]<30,"25-29",[Age]<35,"30-34",[Age]<40,"35-39",[Age]<45,"40-44",[Age]<50,"45-49",[Age]<60,"50-59",[Age]<100,"60-99") AS AgeGrp
FROM Convicts
GROUP BY Switch([Age]=-1,"Unknown",[Age]<15,"10-14",[Age]<20,"15-19",[Age]<25,"20-24",[Age]<30,"25-29",[Age]<35,"30-34",[Age]<40,"35-39",[Age]<45,"40-44",[Age]<50,"45-49",[Age]<60,"50-59",[Age]<100,"60-99")
PIVOT Convicts.Gender;
The total row is added by clicking the Sigma(Totals) icon on the ribbon when query is in Datasheet view.
A simpler calculation will generate more groups:
TRANSFORM Count(Convicts.ID) AS CountOfID
SELECT Partition([Age],0,100,5) AS AgeGrp
FROM Convicts
GROUP BY Partition([Age],0,100,5)
PIVOT Convicts.Gender;
But a little adjustment to the SELECT clause will get same output as the first:
SELECT IIf([Age]=-1,"Unknown",IIf([Age]<50,Partition([Age],0,50,5),IIf([Age]<60,"50:59","60:99"))) AS AgeGrp
Could add a field in table and use one of those expressions in UPDATE action SQL to add calculated AgeGrp, which would simplify the CROSSTAB and other queries needing that group identifier.

Aggregate function in group header?

I have a really simple recordset by the name of qryUserFiles:
string: [UserID], [ftype]; Long: [fsize]
(records are file-information details of each file in each users' userfolder on the file-server)
I have created a report which lists the sum of [fsize] for each [UserID] by grouping on [UserID] and putting =Sum([fsize]) in a textbox in the header of the group. So far so good. So that shows me the total size of that user's user-share on the fileserver. (Helpful with respect to both convincing the users to clean up their stuff, and convincing the executives that we need to buy more storage!)
Now the headbanging part.
I want to add, in that same header, various textboxes containing the sum of the [fsize] for various values of [ftype]. So, for example, I'd want the sum of [fsize] for files where ftype="jpg" for each UserID. (And then another sum of [fsize] for files where ftype="mov" for each UserID, and so on for various 'problematic' file-types!)
I tried putting a
Dsum("fsize","qryUserFiles","ftype='jpg'")
in the group header, but, as expected, it is looking at the entirety of the 'qryUserFiles' recordset, and giving me the domain-total of size for jpg, not the this-user-total of size for jpg.
I considered trying to add something to the 'where' clause of the dsum function that would include 'this' user as criteria, but how would I refer to 'this' userID, with respect to the grouping-pointer?
Or is there a way easier way to do what I want without going nuts!? Would this be easier in another query? I feel like there's a simple, obvious answer just out of reach!
(I'm hoping to avoid brute-force VBA code to step through the table record by record, and calculate the stats with Dsum and add them to a new table. But if that's how to do this....)
I think - judging from what I read - you just need to let the report do its stuff. You can group on user and ftype - including the totals in the details and the totals in the Group Footer
You definitely should not use a DSum formula

Sum Values from Dataset based on condition: Report Builder

I have a report where users can select items from various location. And I have 3 datasets performing calculations where the third dataset takes the sum where item number is 4942200 and then calculates the values (as shown below):
=SUM(IIf(Fields!masterno.Value= "4942200",Fields!Owned.Value,0))+SUM(IIf(Fields!masterno.Value= "4942200",Fields!Subbed.Value,0))
This is returning error for some reason. The subbed column is toggled based on parameter (visibility). But before I add the toggle functionality, I want to make sure this is working. Can anyone help. I have also tried:
=SUM(IIf(Fields!masterno.Value= "4942200",Fields!Owned.Value+Fields!Subbed.Value,0))
This seems to fail as well. Help would be greatly appreciated.
I would wrap a CDec around Owned, 0 and Subbed, e.g.
=SUM(IIf(Fields!masterno.Value= "4942200",CDec ( Fields!Owned.Value) ,CDec (0 ) ))+SUM(IIf(Fields!masterno.Value= "4942200",CDec (Fields!Subbed.Value ) ,CDec ( 0 )))
If Owned and Subbed are already Decimals, those CDec's may be redundant. On the other hand SSRS doesnt expose this info and they can change at the whim of the data source.

stuck in microsoft report

My report is containing some null value.
Report is generated through query
In my report I am calculating sum of every field for that I had written =iif((field name) is null,0,sum(field name))
Through this function I am getting result as 0 only if field contains some value as well
I agree with Remou, you should be using the footers for totals. However if you wanted to carry on with the way you are doing things then try replacing the IIF with NZ(MyField,0)
You should put that IIf statement in the query for that (or those) fields that you want to avoid nulls on. That way you can just put the Sum function in the details section of the report with impunity (assuming details section here).