How to get desired output in row RDLC report - reporting

I have the following report below i can get all the rows
SERVER NAME COUNT1 COUNT2 Count+% 7days count+% 30days
All Servers
( Server1,
Server2,
Server 3) 7 1,501 500 (20%) 850 (53.3%)
Server 1 2 705 200 (28.3%) 350 (49.6%)
Server 2 3 396 100 (25.2%) 200 (50.5%)
Server 3 2 400 200 (50%) 300 (75%)
I have done the last three rows, but how to get the top row? How can we sum up all the rows.In the top row as above?
the others are simple countDistint and count ,
For Count+ % students :
=Sum(IIf(Fields!Logged7Days.Value = "no", 1, 0)) &" ( "& FormatNumber((Sum(IIf(Fields!Logged7Days.Value = "no", 1, 0)) *100) / count(Fields!f_IdPupil.Value),2) & "%) "
And simply change column to 30days , for the next one basically they tell if the student was present in 7 days, 30 days time.
SAMPLE DATA:
Thank you

You can use your expression in any table/group header row; it will just be applied in that current scope, e.g. in a group header the aggregate will be applied to all rows in the group, and in a table header it will be applied to all rows in the dataset.
Say I have the following data:
I've created a simple report based on this:
You can see there are two table header rows, one with headings and one with data, and one group header row - the group is based on ServerName.
For the 7 Day Expression column both the fields in the table header row and the group header row have exactly the same expression:
=Sum(IIf(Fields!Logged7Days.Value = "no", 1, 0))
& " ( "
& FormatNumber((Sum(IIf(Fields!Logged7Days.Value = "no", 1, 0)) * 100)
/ count(Fields!f_IdPupil.Value),2) & "%) "
The is just your exact same expression with some minor formatting. A similar expression is applied in the 30 Day Expression column:
=Sum(IIf(Fields!Logged30Days.Value = "no", 1, 0))
& " ( "
& FormatNumber((Sum(IIf(Fields!Logged30Days.Value = "no", 1, 0)) * 100)
/ count(Fields!f_IdPupil.Value),2) & "%) "
You can see the results are as expected at both the group and grand total levels:
All this is to show that you just need to apply the same expression in the different scopes to get your results. If this doesn't look right to you; please let me know what results you expect based on my dataset.

Related

Power Bi - Add Total Average column in Matrix

Hi I am trying to add a AVERAGE column in a matrix, but when I put my metric added the average per column, but I need a total AVERAGE and total at the end just once
What I have:
What I need:
Group
Maria
Pedro
average
total
First
4
6
5
10
Second
5
10
7.5
15
Regards
Following the example detailed in the sample data table, to get the Total you could add the following measure;
Total By Group = CALCULATE( SUM(AverageExample[Maria]) + SUM(AverageExample[Pedro]))
and to average
Average By Group = [Total By Group] / 2
Based on the first three columns, this will provide
You have to build a DAX table (or Power Query) and a designated measure.
Matrix Table =
UNION(
DATATABLE("Detail", STRING, "Detail Order", INTEGER, "Type", STRING, {{"Average", 1000, "Agregate"}, {"Total", 1001, "Agregate"}}),
SUMMARIZE('Your Names Table', 'Your Names Table'[Name], 'Your Names Table'[Name Order], "Type", "Names")
)
This should give you a table with the list of people and 2 more lines for the agregations.
After that, you create a measure using variables and a switch function.
Matrix Measure =
var ft = FIRSTNONBLANK('Matrix Table'[Type], 0)
var fd = FIRSTNONBLANK('Matrix Table'[Detail], 0)
return SWITCH(TRUE,
ft = "Names", CALCULATE([Total], KEEPFILTERS('Your Names Table'[Name] = fd)),
fd = "Total", [Your Total Measure],
fd = "Average", [Your Averagex Measure]
)
The rest is up to you to fiddle with orders, add any agregate measures and whatnot.
Note that the Matrix Table should have no relation with any table from your model.
You can also hide it and the Matrix measure.

How to show a column's content horizontally in Crystal Reports?

I'm new to crystal reports. I'm creating a bill report for clothing store application.
I'm having data like
prodID prodName qty rate amount salesmanID
101 saree 1 500 500 5
108 Legging 1 500 500 7
I want to display report as,
prodID prodName qty rate amount
101 saree 1 500 500
108 Legging 1 500 500
sid : 5 7
How do I achieve this?
In short: use shared variables to collect the salespersonIds within the detail section of your report, and print content of the shared variable at the end of it.
In detail:
Add one formula field to your report and drag it into the detail section. The formula should read like this (replace field name {Befehl.salesmanID}):
// #AddToArrayVar
whileprintingrecords;
numbervar array salespersonArray;
numbervar counter;
// add only new lines
if not({Befehl.salesmanID} in salespersonArray) then
(
counter := counter + 1;
//The line below ensures that the size of the array does
//not exceed 1000 values. An array can contain a maximum
//of 1000 values.
if counter <= 1000
then (
Redim Preserve salespersonArray[counter];
salespersonArray[counter] := {Befehl.salesmanID}
)
);
The formula field must be part of the detail section, you can hide it via field format.
Then add a second formula field for printing the array content and place it in a section after the details, e.g. report footer:
// #PrintFromArrayVar
whileprintingrecords;
numbervar array salespersonArray;
numbervar Counter;
stringvar salespersonslist;
numbervar i;
for i := 1 to Counter do
(
if i > 1 then salespersonslist := salespersonslist + ',';
salespersonslist := salespersonslist + ToText(salespersonArray[i],0,'');
);
salespersonslist;
P.S.: I'm not sure if the 1000 item limitation is still there in current version of Crystal Reports.

SSRS First, Second, Third, etc?

=First(Fields!PrimeContractor.Value, "DataSet1") + ", " + Last(Fields!PrimeContractor.Value, "DataSet1")
This is good to get the first and last values from a field into one single cell, but how do I get everything else in between? I tried "Second" but that is a time value so I know that doesn't work.
You can use the LookupSet to get the selected values in a dataset then use JOIN to put them all together:
=Join(LookupSet(1, 1, Fields!PrimeContractor.Value, "DataSet1"), ", ")
Since you want all records, use 1 and 1 for the first two arguments (1 = 1). This reads as:
Lookup records where 1 = 1 and return the PrimeContractor in the DataSet1 Dataset.

PIG- Aggregations based on multiple columns

My Input data set has 3 columns and schema looks like below:
ActivityDate, EventId, EventDate
Now, using pig i need to derive multiple variables like below in one output file:
1) All Event Ids after ActivityDate >= EventDate -30 days
2) All Event Ids after ActivityDate >= EventDate -60 days
3) All Event Ids after ActivityDate >= EventDate -90 days
I have more than 30 variables like this. If it is one variable, we can use simple FILTER to filter the data.
I am thinking about any UDF implementation which takes bag as input and returns count of Event IDs based on above criteria for each parameter.
What is the best way to aggregate the data on multiple columns in pig ?
I would suggest creating another file with all of your thresholds and cross joining with the file.
so you would have a file containing:
30
60
90
etc
read it like this:
grouping = load 'grouping.txt' using PigStorage(',') as (groups:double);
Then do:
data_with_grouping = cross data, grouping;
Then have this binary condition:
data_with_binary_condition = foreach data_with_grouping generate ActivityDate, EventId, EventDate, groups, (ActivityDate >= EventDate - groups ? 1 : 0) as binary_condition;
Now you will have one column with the threshold and one column with a binary variable that tells you whether the ID follows the condition or not.
you can do a filter out all of the zeros from the binary_condition and then group on the groups column:
data_with_binary_condition_filtered = filter data_with_binary_condition by (binary_condition != 0);
grouped_by_threshold = group data_with_binary_condition_filtered by groups;
count_of_IDS = foreach grouped_by_threshold generate group, COUNT(data_with_binary_condition.EventId);
I hope this works. Obviously, I didn't debug it for you since I don't have your files.
This code will take a tad more time to run, but it will produce the output you need without a UDF.
If I understand your question correctly, you want to divide the difference between EventDate and ActivityDate in 30 days blocks (e.g. 1 to 30, 31 to 60, 61 to 90 and so on) and then count the frequency of each block.
In this case, I would just rearrange the above equation to create the variable 'range' as below:
// assuming input contains 3 columns ActivityDate, EventId, EventDate
// dividing the difference between ED and AD by 30 and casting it to int, so that 1 block is represented by 1 integer.
input1 = FOREACH input GENERATE (int)((EventDate - ActivityDate) / 30) as range;
output1 = GROUP input1 BY range;
output2 = FOREACH output1 GENERATE group AS range, COUNT(range) as count;
Hope this helps.

need help in sum of time in rdlc

I am working on attendance management system.
In my project i want to display total worked hours of the employee in the daily report.
In my database table i have already calculated working hours for the each employee.
Now i want to display Total worked hours of each and every entry at the bottom of the report.
e.g
EmployeeId EmployeeName WorkedHours
1 ABC 04:00:25
2 XYZ 07:23:01
3 PQR 11:02:15
SO i want to display total of all 3 employees at the end of report in RDLC.
like Total: 22:25:42
Please let me know how can i achieve it?
You just need to add =Sum(Fields!WorkedHours.Value) in footer row for "WorkedHours" column.
see the link in MSDN http://msdn.microsoft.com/en-us/library/ms252113(v=vs.80).aspx
You can use the TimeStamp class gether with the Sum function,
follow an example:
=TimeSpan.FromMinutes(Sum(Fields!Dirigindo.Value))
Try This out and see if it works
=(SUM(Cint(Split(Fields!WORKEDHOUR.value,":").GetValue(0))) + (SUM(Cint(Split(Fields!WORKEDHOUR.Value,":").GetValue(1))) + Sum(Cint(split(Fields!WORKEDHOUR.Value,":").GetValue(2)))\60)\60 ).ToString + ":" + ((SUM(Cint(Split(Fields!WORKEDHOUR.Value,":").GetValue(1))) + Sum(Cint(split(Fields!WORKEDHOUR.Value,":").GetValue(2)))\60) Mod 60).ToString + ":" + (Sum(Cint(split(Fields!WORKEDHOUR.Value,":").GetValue(2))) Mod 60).ToString
Facing the same issue here is your final answer.
Step1: Go to your textbox expression and past below code
=Code.MinutesToHoursMinutes(SUM(Hour(Fields!TTShortTime.Value)*60)+SUM(Minute(Fields!TTShortTime.Value)))
Step2: Goto your rdlc report properties => Tab Code, Here past below function
Function MinutesToHoursMinutes(ByVal vMins As Integer) As String
Dim Mins As Integer
Dim Hours As Integer
vMins = IIF(vMins <= 0, 0, vMins)
Hours = Floor(vMins / 60)
Mins = vMins - (Hours * 60)
MinutesToHoursMinutes = IIF(Hours < 9, "0" & CStr(Hours), CStr(Hours)) & ":" & IIF(Mins < 9, "0" &
CStr(Mins), CStr(Mins))
Return MinutesToHoursMinutes
End Function
Here in Step1 we get hours and convert it into minutes then get minutes and sum with hour calculated minutes.
then passes it to function which returns string format like hh:mm

Resources