DevExpress create Dynamic grouping of columns - winforms

I have the following data structure:
public class Person {
public string Name{get;set;}
public List<Finance> {get;set;}
}
public class Finance{
public string Name{get;set;}
public decimal GrossValue{get;set;}
public decimal NettValue{get;set;}
}
Now I want to show the data in a grid as follows
Columns
Name(From Person) Name(From Finance as a Group)
Gross Value NettValue
Names Of People Gross Value NettValue
So it could possibly look like this:
Name Jan Feb Mar
Gross Nett Gross Nett Gross Nett
Joe 100 50 1000 200 200 10
Jill 1000 900 450 11 2220 110
ETC...
Can this be done in DevExpress WinForms Grid if so how?
Thanks in advance

It could be done with an XtraGrid, but the approach would require unbound or calculated columns. The XtraPivotGrid control would usually be a better choice for this sort of thing.

Related

BI - fact table design with incompatible grains

I'm quite new to BI designing DB, and here some point I do not understand well.
I'm trying to import french census data, where I got population for each city. For each city, I have population with different age classification, that can't really relate with each other.
For instance, let's say that one classification is 00 to 20 years old, 21 to 59, and 60+
And the other is way more precise : 00 to 02, 03 to 05, etc. but the bounds are never the same as the first one classification : I don't have 15 to 20, but 18 to 22, for example.
So those 2 classifications are incompatible. How can I use them in my fact table ? Should I use 2 fact tables and 2 cubes ? Should I use one fact table, and 2 dimensions for 1 cube ? But in this case, I will have double counted facts when I'll sum to have total population for a city, won't I ?
This is national census data, and national classifications, so changing that or estimating population to mix those classifications is not an option. And to be clear, one row doesn't relate to one person, but to one city. My facts are not individuals but cities' populations.
So this table is like :
Line 1 : One city - one amount of population - one code for dim age (ex. 00 to 19 yo) of this population - code (m/f) for the dim gender of that population - date of the census
Line 2 : Same city - one amount of population - one code for dim age (ex. 20 to 34) of this population - code (m/f) for the dim gender - date of the census
And so it goes for a lot of cities, both gender, and multiple years.
Same
I hope this question is clear enough, as english is not my native language and as I'm quite new in DB and BI !
Thanks for helping me with that.
One possible solution using a single fact table and two dimensions for the age ranges:
1 - Categorical range based on the broadest census, for example:
Young 0-20
Adult 21-59
Senior 60+
You could then link the other census to this dimension with approximate values, for example 18-22 could be Young.
2 -Original age range. This dimension could be used for precise age ranges when you report on a single city, it can also help you evaluate the impact of the overlapping bounds (e.g. how many rows are in the young / 18-22 range?)
you can crate one dimention as below
young 1-20
adult 21-59
senior 60+
Classification is
young city 1 : 1-20
young city 2 : 4-23
id field1 field2 field3 field4 .......
1 1 year young_city_1 other .......
2 2 year young_city_1 other .......
3 3 year young_city_1 other .......
4 4 year young_city_1 young_city_2 .......
Now you can report from any item and with any division
i hope it is help you

Aggregating grouped data with repeating data

I am trying to figure out how to aggregate the number of hours a person worked that is repeated by each fringe code that they have.
The data looks like this
Company Code Employee Code Employee Name Hours Fringe Code Fringe Amount
030 12345 Joe Blow 8 VAC 10.00
030 12345 Joe Blow 8 DUE 5.00
030 12345 Joe Blow 8 INTDUE 2.00
030 54698 Alan Low 8 VAC 10.00
030 54698 Alan Low 8 DUE 5.00
030 54698 Alan Low 8 INTDUE 2.00
Now the total number of hours should by 16. In the report I have grouped the following fields Company Code, Employee Code, Employee Name, Hours so that they only appear once (not sure how to show that).
I tried to do the following
Sum(FIRST(Fields!Hours.Value, "Employee_Name") , "Company_Code")
but I get an error saying that the value is using a First aggregate in an outer aggregate and that they cannot be specified as nested aggregates.
Any ideas?
I am not sure what you want so I guess a possible result scenario.
I 've reproduced the providing input table.
Using this tablix data settings:
Add this code to the report. This function will flag those rows that must be summed.
Dim groups As System.Collections.Hashtable
Function MyFunc(ByVal group As Object) As integer
dim flag as integer
If (groups Is Nothing) Then
groups = New System.Collections.Hashtable
End If
If (Not groups.Contains(group)) Then
flag = 1
groups.Add(group, nothing)
else
flag = 0
End If
MyFunc = flag
End Function
And this expression in the tablix textbox you want to put the sum.
=sum(val(iif(Code.MyFunc(Fields!Employee_Code.Value) = 1, Fields!Hours.Value, 0)))
You'll get this preview
Let me know if this was helpful.
Well I had issues with some of the above suggestions but I figured out how to solve the problem.
I used the following equation:
=SUM(MAX(Fields!Regular_Hours.Value, "Employee_Code","Company_Code")
Thus I used the MAX function to get only one occurrence per Employee Code and then did a sum of that one occurrence over the Company Code grouping.
Thanks for your guys help!

Arrays in raptor

How can I store an array in my raptor program so I can refer to it for the entire program?
This is what the program's output should look like:
Day Calories Consumed Calories Burned
Monday 2600 150
Tuesday 2400 100
Create a class with three properties
day
caloriesConsumed
caloriesBurned
Declare a property in your controller
private Result result;
After serialize a list of objects in your controller.
result.include("listObjects", List< YourObject >);

How to sum SSRS Matrix Columns on Row Group

I have a report that displays the total hours a person worked for each project they are assigned to, aggregated on month. I would like to sum the total hours for each person, for each month, in SSRS 2008 R2. So, for example, I have the follow data and would like to column totals like so:
January February March
Worker 1
Project1 50 80 20
Project2 30 10 60
Project3 10 40 5
Total: 90 130 80
Worker 2
Project1 20 40 60
Project2 10 30 10
Porject3 30 10 50
Total: 60 80 120
Everything I have tried so far either sums each column for all workers combined (summing by 'Month' column group) or sums all hours for each worker (Summing by 'Person' row group).
For completeness, my row groups are:
Person
Project
RowGroup
My Column groups are:
Month
ColumnGroup
I know that I can create another query/data set to do this, but I was hoping that SSRS can do this fairly easily. It seems like a trivial problem and perhaps I am just missing something.
Any help would be great or perhaps this is something that SSRS can't do.
If you are trying to add a Column containing totals, it is pretty simple just
right click on cell --> Totals --> Column
As shown here

Can one Entity contain two different Entities of the same type, uniquely accessible?

Forget databases and tables for a moment. Say I have a class Spaceship and a class Person. If I am writing the Contract model, I might do this:
public class Spaceship {
public string LicensePlate { get; set; } //
public string Destination { get; set; } //Regular old data
public Person Captain { get; set; }
public Person Engineer { get; set; }
}
because the captain and the engineer are both people, and while their relevant information may be slightly different, they'll stay the most DRY if they're the same type.
But what if I wanted to make this kind of relationship in an Entity Framework? If I were drawing it up in Entity designer, I would make a relationship like this:
--------------------- ---------------------
| Spaceship | | Person |
|---------------------| |---------------------|
| LicensePlate | | Name |
| Destination | | PhoneNumber |
|---------------------| |---------------------|
|Navigation Properties| |Navigation Properties|
| People |1---------------*| Spaceship |
--------------------- ---------------------
But this is not the same thing. Because while the two People can accurately share the same class, their relationship with the Spaceship is fundamentally different. I want to have a dbContext where I can say
Spaceship Enterprise = new Spaceship();
Enterprise.Captain = People.Find("Kirk");
Enterprise.Engineer = People.Find("Scotty");
Is that too much to ask? I mean, sure, there are other ways. Person could have a Role that would be "Captain" or "Engineer," and then you could lump them all into Enterprise.People. You could even make a GetCaptain() method on Spaceship if you need to access the captain a lot.
But, in the interest of education,
Is that possible?
If so, what are the consequences on the actual database schema?
What's the best way?
You could add Engineer and Captain tables with a zero-or-one-to-one relationship with the Person table which would give you your two navigation properties for the Spaceship. This approach could be useful if your model changes and either sub-type ends up requiring new properties or methods.

Resources