How to get total from grouped row - reporting

I try to get the total hours for a Employee
My Report should look like:
GROUP "Month" | Details
Month | WorkHoursMonth | section | Hours STATIC
---------------------------------------- --------------
| | A1 | 12
1 | 50 | B3 | 38
----------------------------------------
| | A1 | 12
2 | 50 | B3 | 38
---------------------------------------- GROUP "Month"
| | A1 | 12
3 | 62 | B3 | 38
| | C1 | 12
----------------------------------------
4 | 38 | B3 | 38
---------------------------------------- --------------
Total | 200 STATIC Total
I tryed to use SUM() like SUM(Field.WorkHoursMonth.Value,"Month").
but i get an ERROR
Fehler 1 Der Value-Ausdruck für das Textfeld-Objekt 'SollStunden1'
weist einen Bereichsparameter auf, der für eine Aggregatfunktion
ungültig ist. Der Bereichsparameter muss auf eine
Zeichenfolgenkonstante festgelegt sein, die einem der folgenden Werte
entspricht: dem Namen einer enthaltenden Gruppe, dem Namen eines
enthaltenden Datenbereichs oder dem Namen eines Datasets.
Update 1
The problem is my current Total is 424 instead of 200 but i don't know how to make a total at the end for the group which based on the error has to be inside the group.
GROUP "Month" | Details
Month | WorkHoursMonth | section | Hours STATIC
---------------------------------------- --------------
| | A1 | 12
1 | 50 | B3 | 38
----------------------------------------
| | A1 | 12
2 | 50 | B3 | 38
---------------------------------------- GROUP "Month"
| | A1 | 12
3 | 62 | B3 | 38
| | C1 | 12
----------------------------------------
4 | 38 | B3 | 38
---------------------------------------- --------------
Total | 424 STATIC Total
Update 2

First of all, I believe you might have made a typographical error:
I tryed to use SUM() like SUM(Field.WorkHoursMonth.Value,"Month"). but i get an ERROR
=SUM(Fields!WorkHoursMonth.Value,"Month")
But I doubt this is the cause of your issue, based on your error message. I believe you either didn't group correctly or your group just isn't called "Month".
You could try to remove the scope definition and simply use the following expression, just make sure it's still inside your group.
=SUM(Fields!WorkHoursMonth.Value)
Edit: I didn't realize that the WorkHoursMonth was the same for all rows and not being grouped on. Who knew this would cause so many issues for trying to calculate the total...
The grouping you have set up seems to be correct as long as the WorkHoursMonth value is the same for the entire month, which it seems to be in your case.
The following expression should then calculate your wanted total:
=Sum(Max(Fields!WorkHoursMonth.Value,"Month"))

Just use [sum(month)] place this on your total

Related

Custom Week number from Acquistion Date of each User

Is there a way to calculate Custom Week numbers that start from a user's first Transaction Date onwards? The Users (emailId) and TransDate columns may not be in a sorted condition as shown below:
e.g.
+------+-------------+---------------------+
| WkNo | TransDate | emailId |
+------+-------------+---------------------+
| 1 | 2018-Aug-30 | moz.shea#abc.com |
| 1 | 2018-Aug-30 | moz.shea#abc.com |
| 10 | 2018-Nov-07 | moz.shea#abc.com |
| 1 | 2018-Aug-09 | zabi.prado#abc.com |
| 1 | 2018-Aug-09 | zabi.prado#abc.com |
| 6 | 2018-Sep-20 | zabi.prado#abc.com |
| 15 | 2018-Nov-23 | zabi.prado#abc.com |
| 21 | 2018-Dec-31 | zabi.prado#abc.com |
| 1 | 2018-Aug-20 | silo.whitte#abc.com |
| 5 | 2018-Sep-23 | silo.whitte#abc.com |
| 7 | 2018-10-11 | silo.whitte#abc.com |
| 7 | 2018-10-11 | silo.whitte#abc.com |
| 8 | 2018-Oct-14 | silo.whitte#abc.com |
| 9 | 2018-Oct-19 | silo.whitte#abc.com |
| 1 | 2018-Jul-01 | pablo.gucci#abc.com |
| 6 | 2018-Aug-10 | pablo.gucci#abc.com |
| 13 | 2018-Oct-03 | pablo.gucci#abc.com |
+------+-------------+---------------------+
I wrote the following formula using FILTER function that then supplies the filtered dates per user to the DATEDIF function. However, i am not getting the desired result as shown above.
=ARRAYFORMULA(if(B2:B="","",1 + round(DATEDIF(min(sort(FILTER(B2:B,C2:C=C2:C),1,true)),sort(FILTER(B2:B,C2:C=C2:C),1,true),"D")/7)))
EDIT:
Formula Result:
1
7
7
7
8
10
10
13
13
14
16
16
16
17
19
22
27
Also removed SORT from above formula:
=ARRAYFORMULA(if(B2:B="","",1 + round(DATEDIF(min(sort(FILTER(B2:B,C2:C=C2:C),1,true)),FILTER(B2:B,C2:C=C2:C),"D")/7)))
Formula Result:
10
10
19
7
7
13
22
27
8
13
16
16
16
17
1
7
14
Both seem to work, but give unexpected results as MIN is evaluating to a single date 2018-Jul-01 instead of an Array of Minimum dates per user. Where am i going wrong?
Did you try using the MINIFS() function ?
EG with the following
Dates in cells B2:B10
Emails in Cells C2:C10
The formula in cell A2 would give the earliest date for the email address in Cell C2
=MINIFS($B$2:$B$10, $C2:$C10, "="&C2)
You should be able to use this in your formula to calculate the number of weeks
For those who might face a similar challenge, here is the answer:
=ARRAYFORMULA(IF(B2:B="","",ROUND((B2:B-VLOOKUP(C2:C,SORT({C2:C,B2:B},2,1),2,0))/7)+1))
The idea is to do a Vlookup on column C, passing it a switched and sorted range of dates in ascending order. These first dates are then deducted from the B column dates, to get the desired result ie. either days or weeks.
One can remove the +1 as i used it just to display the starting week as 1 instead of 0. So the result may differ slightly. But without +1, the result is accurate, especially if you are doing a Cohort.
0
0
10
0
0
6
15
21
0
5
7
7
8
9
0
6
13
As a check, i removed division by 7 and +1, then checked the days, which are correct.
0
0
69
0
0
42
106
144
0
34
52
52
55
60
0
40
94
Hope this helps.

Hive Query for ROlling total based on 2 fields

I have a table a show below
Date | Customer | Count | Daily_Count | ITD_Count
d1 | A | 3 | 3 |
d2 | B | 4 | 4 |
d3 | A | 7 | 16 |
d3 | B | 9 | 16 |
d4 | A | 8 | 9 |
d4 | B | 1 | 9 |
Descrption of Fields:
Date : date
customer : name of customer
Count : # of customers
daily_Count : # of customers on daily basis calculated as
SUM(count) OVER (partition BY date )as Daily_Count
Question :
How do I calculate the Running Total or Rolling Total in the ITD_Count ?
The output should look like
Date | Customer | Count | Daily_Count | ITD_Count
d1 | A | 3 | 3 | 3
d2 | B | 4 | 4 | 7
d3 | A | 7 | 16 | 23
d3 | B | 9 | 16 | 23
d4 | A | 8 | 9 | 31
d4 | B | 1 | 9 | 31
I have tried several variations of using the Window functionality.. But hit a road-block in all my attempts.
Attempt 1 ;
SUM(daily_COunt) OVER (partition BY date order by date rows between unbounded preceding and current row ) as ITD_account_linking
Attempt 2 :
SUM(daily_COunt) OVER (partition BY date, daily_count order by date rows between unbounded preceding and current row ) as ITD_account_linking
and several more attempts following this. :(
Any possible suggestions to guide me in the right direction are welcome.
Please let me know if you need more details.
Use Hive Windowing and Analytics functions.
SELECT Date, Customer, Count, Daily_Count,
SUM(Daily_Count) OVER (ORDER BY Date ROWS UNBOUNDED PRECEDING) AS ITD_Count
FROM table;

Get the best route between two dirrent paths in wp8

I have created a bus transit application for a city in windows phone 8. I have stored all my routes and bus stops in a separate table in the database.
My bus stop table contains:
stop_id | stop_name | latitude | longitude | status | alias_name
---------------------------------------------------------------------------------------
1736 | Atlas Company | 18.629243 | 73.833814 | Active | Centurenca Corner
1737 | Atlas company | 18.629243 | 73.833814 | Active |
681 | Atma Anand Dhyan Kendra | 18.600349 | 73.926251 | InActive |
My Routes Table contains
bus_id | bus_no | bus_source | bus_destination | days_of_week | total_distance estimated_time | source_stop_names | destination_stop_names | total_stops | source_trip_time | destination_trip_time | bus_status
source_stop_names contains
-----------------
1 | Swargate
2 | Parvati payatha
3 | Dandekar pul
4 | Pan mala Sinhgad Road
5 | Jal Shuddhikarn Kendra Sinhgad Road
6 | Ganesh mala
7 | Vitbhatti Sinhgad Road
8 | Vitthalwadi jakat naka
9 | Jaydeo nagar
10 | Rajaram pul
11 | Vitthalwadi Mandir Hingne
12 | Hingne rasta
13 | Anand nagar singhgad rd
14 | Manik Bag
15 | Indian hum company
16 | Wadgaon phata
17 | Patil colony
18 | Dhayari phata
19 | Sanas Vidyalaya
20 | Dangat wasti
21 | Gar mala
22 | Dhayarai gaon
23 | Raykar wasti
24 | Poultry farm singhgad road
25 | Dhayarigaon shala
26 | Chavan mala
27 | DSK Vishwa
I want to find the shortest path between two bus stops not connected by a bus route, and show the number of routes and buses the user has to take while travelling from one point to another, like google maps does.
I have used default map control in windows phone 8.

PL/SQL getting average value in case statement

THE TABLE:
+-----+----+----------+
| QTR | MO | PCT_PERF |
+-----+----+----------+
| 1 | 1 | 89 |
| 1 | 2 | 73 |
| 1 | 3 | 95 |
+-----+----+----------+
What is the proper syntax for this?
CASE WHEN QTR=1 THEN ROUND(SUM(PCT_PERF WHERE MO IN (1,2,3))/3,2)
WHEN QTR=2 THEN ROUND(SUM(PCT_PERF WHERE MO IN (4,5,6))/3,2)
WHEN QTR=3 THEN ROUND(SUM(PCT_PERF WHERE MO IN (7,8,9))/3,2)
ELSE ROUND(SUM(PCT_PERF WHERE MO IN (10,11,12))/3,2) END QTR_PCT
So that WHEN QTR is 1, QTR_PCT should be 86.
(89+73+95)/3 = 85.67
I believe Oracle's AVG ("average") function should solve your problem. I don't have an Oracle database handy to confirm this:
SELECT QTR, ROUND(AVG(PCT_PERF), 2) AS QTR_PCT FROM ... GROUP BY QTR

How to setup a header in a pivot (CrossTab) report (MS Report Designer)

I have the following table which I'd like to turn into a report:
ClientGroup | Product | Client | Quantity
-----------------------------------------
Gr1 | P1 | C1 | 10
Gr1 | P1 | C2 | 20
Gr1 | P1 | C3 | 30
Gr1 | P2 | C1 | 40
Gr1 | P2 | C2 | 50
Gr1 | P2 | C3 | 60
Gr2 | P1 | C4 | 70
Gr2 | P1 | C5 | 80
Gr2 | P1 | C6 | 90
Gr2 | P2 | C4 | 100
Gr2 | P2 | C5 | 110
Gr2 | P2 | C6 | 120
The report would have the following layout:
--------------------
| G1 |
--------------------
Client | P1 | P2 |
--------------------
C1 | 10 | 40 |
C2 | 20 | 50 |
C3 | 30 | 60 |
--------------------
Total | 60 |150 |
--------------------
| G2 |
--------------------
Client | P1 | P2 |
--------------------
C4 | 70 | 100 |
C5 | 80 | 110 |
C5 | 90 | 120 |
--------------------
Total | 240 | 330 |
--------------------
What I'm doing is to create a Matrix, add a row group on ClientGroup, a sub group row on Client, a column group on Product with Quantity as detail. In the designer it looks somewhat like this:
---------------------------------------------
| ClientGroup | Client | [Product] |
---------------------------------------------
| [ClientGroup] | [Client] | Sum([Quantity])|
---------------------------------------------
I then hide the ClientGroup column and it seems I'm almost there. What I can't figure out is how to have a header over the columns Client and [Product] displaying the current ClientGroup.
Is it possible? Any ideas?
You can get pretty close:
Set the Headings row to be hidden.
Right-click the [Client] cell and select Insert Row > Outside Group - Above, twice.
Copy [ClientGroup] into the left-hand cell on the first new row, and set the BorderStyle-Right of the cell to be None.
Select the right-hand cell on the first new row, and set the BorderStyle-Left and -Right of the cell to be None.
Copy the heading Client into the left-hand cell on the second new row.
Copy [Product] into the right-hand cell on the second new row.
Your report should look something like this in the designer:
--------------------------------------------------
| ClientGroup | Client | [Product] |
--------------------------------------------------
| [ClientGroup] | [ClientGroup] | |
| |---------------------------------
| | Client | [Product] |
| |---------------------------------
| | [Client] | Sum([Quantity])|
--------------------------------------------------
If you preview it, the results should be pretty close to the desired layout.

Resources