i have a question on Crystal Report, i have a query that return a list of name that a free slots in the morning and free slots in the afternoon. A person can have 1 or several free slots in the morning or afternoon. The query return something like that:
NAME | HALFDAY
Jean | 1
Jean | 1
Jean | 2
Martin | 2
Martin | 2
Martin | 2
Francois | 1
Francois | 1
Francois | 1
1 is for the morning, 2 is for the afternoon.
So, Jean have 2 free slots in the morning and one in the afternoon.
Martin has 3 free slots in the afternoon.
I would like my report looks like that:
Jean 2 / 1
Martin 0 / 3
Francois 3 / 0
But i don't know how to do that. Any ideas please?
Thanks a lot!
First group by customer
Create multiple formulas like
If halfday=1
Then 1
Else 0
If halfday=2
Then 2
Else 0
Now take the count of every formula in group footer
Take saperate formula in group footer
Write below code
Databasefield.customernam & totext(count of formula1) & "/" & totext (count of formula 2) //so on
Related
Data
Datapull | product | value
8/30 | X | 2
8/30 | Y | 3
8/30 | Y | 4
9/30 | X | 5
9/30 | Y | 6
Report
date range dimension: datapull
dimensions: data pull & product
metric: running delta of record count
Chart
For 8/30, The totals to start for product Y are right but Product X shows nothing when the first row of data has an entry for product X in 8/30.
The variances in 9/30 are wrong too.
Can someone please let me know if there is a way to do running deltas with 2 dimensions? This is not calculating correctly.
Using the combination of Breakdown dimension and Running delta calculation brakes the chart!
If you not mind to create a field for each Breakdown dimension (product), this will work:
case when product="X" then 1 else 0 end
And put each of these fields into 'Metric':
For the dataset like the following
I want to change the value of G7_A6 which is either 1 or 2 based on B1_04. For a given ID (there are two same IDs) G7_A6 takes either only 1 or only 2.
I need to use loops in Stata [enter image description here][1] because I have a very large dataset and typing individual IDs is cumbersome
replace G7_A6="2" if B1_04=="3" | B1_04 =="4" | B1_04 == "5" | B1_04 =="6" |B1_04 =="7"
replace G7_A6="1" if B1_04=="2"
The link of picture is here
[1]: https://i.stack.imgur.com/Yv7RI.png
You do not need a loop program for this, as each relationship is row-specific. The code you are using would solve your problem but is a bit cumbersome. A cleaner version would be:
replace G7_A6 = 2 if B1_04 != 1 | B1_04 != 2
replace G7_A6 = 1 if B1_04 == 1 | B1_04 == 2
This will give you the following data:
id
name
B1_04
G7_A6
1
sam
2
1
1
margaret
1
1
9
Jim
5
2
9
Cinderella
1
1
You did not post a question either: you simply said you need a program to do what you already posted.
I have been working with country-level survey data in Stata that I needed to reshape. I ended up exporting the .dta to a .csv and making a pivot table in in Excel but I am curious to know how to do this in Stata, as I couldn't figure it out.
Suppose we have the following data:
country response
A 1
A 1
A 2
A 2
A 1
B 1
B 2
B 2
B 1
B 1
A 2
A 2
A 1
I would like the data to be reformatted as such:
country sum_1 sum_2
A 4 4
B 3 2
First I tried a simple reshape wide command but got the error that "values of variable response not unique within country" before realizing reshape without additional steps wouldn't work anyway.
Then I tried generating new variables conditional on the value of response and trying to use reshape following that... the whole thing turned into kind of a mess so I just used Excel.
Just curious if there is a more intuitive way of doing that transformation.
If you just want a table, then just ask for one:
clear
input str1 country response
A 1
A 1
A 2
A 2
A 1
B 1
B 2
B 2
B 1
B 1
A 2
A 2
A 1
end
tabulate country response
| response
country | 1 2 | Total
-----------+----------------------+----------
A | 4 4 | 8
B | 3 2 | 5
-----------+----------------------+----------
Total | 7 6 | 13
If you want the data to be changed to this, reshape is part of the answer, but you should contract first. collapse is in several ways more versatile, but your "sum" is really a count or frequency, so contract is more direct.
contract country response, freq(sum_)
reshape wide sum_, i(country) j(response)
list
+-------------------------+
| country sum_1 sum_2 |
|-------------------------|
1. | A 4 4 |
2. | B 3 2 |
+-------------------------+
In Stata 16 up, help frames introduces frames as a way to work with multiple datasets in the same session.
I have two tables in SQL Server i.e.
one table is GraphNodes as:
---------------------------------------------------------
id | Node_ID | Node | Node_Label | Node_Type
---------------------------------------------------------
1 677 Nuno Vasconcelos Author 1
2 1359 Peng Shi Author 1
3 6242 Z. Q. Shi Author 1
4 8318 Kiyoung Choi Author 1
5 12405 Johan A. K. Author 1
6 26615 Tzung-Pei Hong Author 1
7 30559 Luca Benini Author 1
...
...
and other table is GraphEdges as:
-----------------------------------------------------------------------------------------
id | Source_Node | Source_Node_Type | Target_Node | Target_Node_Type | Year | Edge_Type
-----------------------------------------------------------------------------------------
1 1 1 10965 2 2005 1
2 1 1 10179 2 2007 1
3 1 1 10965 2 2007 1
4 1 1 19741 2 2007 1
5 1 1 10965 2 2009 1
6 1 1 4816 2 2011 1
7 1 1 5155 2 2011 1
...
...
I also have two tables i.e. GraphNodeTypes as:
-------------------------
id | Node | Node_Type
-------------------------
1 Author 1
2 CoAuthor 2
3 Venue 3
4 Paper 4
and GraphEdgeTypes as:
-------------------------------
id | Edge | Edge_Type
-------------------------------
1 AuthorCoAuthor 1
2 CoAuthorVenue 2
3 AuthorVenue 3
4 PaperVenue 4
5 AuthorPaper 5
6 CoAuthorPaper 6
Now, I want to calculate clustering coefficient for this graph i.e of two types:
If N(V) is # of links b/w neighbors of node V and K(V) is degree of node V then,
Local Clustering Coefficient(V) = 2 * N(V)/K(V) [K(V) - 1]
and
Global Clustering Coefficient = 3 * # of Triangles / # of connected Triplets of V
The questions is, how can I calculate degree of a node? Is it possible in SQL Server or C# programming required. And also please suggest hints for calculating Local and Global CCs as well.
Thanks!
The degree of a node is not "calculated". It's simply the number of edges this node has.
While you can try to do this in SQL, the performance will likely be mediocre. Such type of analysis is commonly done in specialized databases and, if possible, in memory.
Count the degree of each vertices as the number of edges connected to it. Using COUNT(source_node) and GROUP BY(source_node) will be helpful in this case.
To find N(V), you can join the edge table with itself and then take the intersection between the resulting table and edge table. From the result, for each vertex take the COUNT().
I just need a little help for my homework. I did my best think about the logic but it's too late. So basically, this is what I need to do :
If I'll check the checkbox 1 it will automatically input "100" on the second column of my datagridview and also if I'll check checkbox 2 it will also input "50" on my 3rd column.
[ ] Fee1 (checkbox1) = $100
[ ] Fee2 (checkbox2) = $50
The output should look like this:
StudentFeeTableGridView
Name| Fee 1| Fee 2
Jack | 0 | 50
Jill | 100 | 0
John | 100 | 0
Jose | 0 | 50
Thank you so much guys for helping! I owe you.
Set DataGridView.SelectionMode=FullRowSelect and use CheckedChanged event. With code below, values will be inserted to cells in selected row:
For 1 checkbox:
If (Fee1.checked=True) Then dataGridView1.CurrentRow.Cells("Fee1").Value="100"
For 2 checkbox:
If (Fee2.checked=True) Then dataGridView1.CurrentRow.Cells("Fee2").Value="50"
Note: .Cells("Fee1") and .Cells("Fee2") must be valid column name in DataGridView.