Consider the below records which retrieved from database,
My xsd datatable fields are,
categoryName
categoryType
prize
Datatable records
category name - category type - prize
--------------------------------------
c1 - 1 - 10
c2 - 1 - 20
c3 - 2 - 10
c4 - 2 - 10
c5 - 1 - 30
c6 - 2 - 30
c7 - 1 - 10
c7 - 2 - 10
Expected report output to be in report as given below,
summary of category
category name - pize | category name - prize
c1 - 10 | c3 - 10
c2 - 20 | c4 - 10
c5 - 30 | c6 - 30
c7 - 10 | c7 - 10
|
Total type1 | Total type2
prize - 70 | prize - 60
Grand total - 130
please help anyone how to achieve this?
Create 2 subreports. Put them side-by-side outside the details section. For example, in the page header. Make the layout (category name and prize columns).
Change the subreport links. The one to the left shall be filtered by type1. The one to the right shall be filtered by type2.
In another section below (may be the page footer), put the two running total fields side-by-side. One of them shall summarize by type1 and the other by type2.
Add another section below and put the grand total.
No need of sub report instead use the cross tab in main report and take first column as type and second as category and for summation part take price you will get required output
Related
Consider a table
StudentId
Subject
Marks
1
Maths
34
1
Science
54
2
Maths
64
2
French
85
2
Science
74
I'm looking for an output where it will give (note that I'm trying to find MAX marks for each student, irrespective of the subject)
StudentId
Subject
Marks
1
Science
54
2
French
85
Use the summarize operator:
T
| summarize max(Marks) by StudentId
In addition to above query from #Avnera, if you also care about the corresponding subject in which the student received the maximum marks (it seems like that based on your desired output table), you can use the arg_max function:
T
| summarize arg_max(Marks, Subject) by StudentId
arg_max(): https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/arg-max-aggfunction
I have a database of NBA basketball. In it are two different tables, one has info on games that have been played and the other table has player information.
In the Game_Detail table, I have the teams, game date, and scores for each team. I also have 10 columns with the 5 starting players from each team.
Game_Detail Table
Date HomeTeam AwayTeam H_Pts A_Pts H1 H2 H3 H4 H5 A1 A2 A3 A4 A5
1/1 ORL BOS 100 99 1 22 32 55 692 12 33 55 333 90
In the 10 columns H1 through A5, each row has a player ID.
In the Player_Detail table with player information, there is the player ID as well.
Player_Detail Table
player_id name height weight
For every row of H1 through A5 in the first table, the Game_Detail table, I want to replace the player_id with the weight of the player (one of the columns in the Player Detail table).
What is the best way to go about doing this? I'm a SQLite/SQL new user so not sure on best practice as it's a large file. The code I have tried so far to run this is not working at all.
Also, does the command change at all if I want to use name instead of weight (seeing as it's a different type, string instead of integer)?
You can use (a lot of) joins.
SELECT gd01.date,
gd01.hometeam,
gd01.awayteam,
gd01.h_pts,
gd01.a_pts,
pd01.weight,
pd02.weight,
...
pd09.weight
pd10.weight
FROM game_detail gd01
LEFT JOIN player_detail pd01
ON gd01.h1 = pd01.player_id
LEFT JOIN player_detail pd02
ON gd01.h2 = pd02.player_id
...
LEFT JOIN player_detail pd09
ON gd01.a4 = pd09.player_id
LEFT JOIN player_detail pd10
ON gd01.a5 = pd10.player_id;
If you want another detail just change the column references, e.g. from weight to name.
I'm new to Power Bi, followed most of the tutorial on MS but haven't figured yet how creat a graph that resembles this graphic I did with Excel - Pivot Graph, using as source the same data table.
What I need to recreate in Power Bi is a column graph with the most requested (pre-orders requests % of total sum) products in different price ranges.
Pivot Graph
Table ie.
| Date | Product | 3 to 5 Eur | 5 to 8 Eur | 8 to 11 Eur |
----------------------------------------------------------
| mar17| Coffe | 12 | 7 | 2 |
| mar17| Milk | 15 | 3 | 1 |
| mar17| Honey | 17 | 0 | 5 |
| mar17| Sugar | 20 | 9 | 8 |
Thank in advance for the help.
Bests,
Alberto
Edit - Thanks to Mike Honey for pointing out the original request was for % of grand total. I have added an additional step to accomplish this and cleaned up some existing steps.
When I imported your sample data into Power BI, I got this (looking at the data in the Query Editor window).
From there, Select the Data and Product columns and then click on Transform -> Unpivot Columns -> Unpivot Other Columns...
... which results in this.
Just to clean this up, I renamed the Attribute and Value columns and changed the data type of the Value column. In the end, it looks like this.
Then just click on Home -> Close & Apply to get back in the Report Editor window, where you can create a graph and configure it as shown such:
Axis:
Price Range
Product
Value:
Quantity
Then click of the forked, drill-down arrow in the top left corner of the graph to show Price Range and Product.
Which looks like this.
Next, while not necessary I feel that it is very nice, with the graph selected, click on the paint roller icon and expand the X-Axis category. In there, turn off Concatenate labels.
Finally, to get the bars to be % grand total, simply right click on Quantity in the Value section of the graph's fields and then select Show value as -> Percent of grand total.
To get the final results that look like this.
I have a report where I want to display data obtained by a stored procedure which returns single table.
Columns returned from stored procedure
Client #, Client Name, Client Phone #
Project #, Project Description
Test #, Test Name, Test Description
Container #, Container Description, Container Parameter
Relationship between tables
Client - Project 1-N(one to many)
Project - Test 1-N(one to many)
Test - Container 1-N(one to many)
Desired format to be displayed
Client # : XYZ Client Name : Patterson, Celeste Phone # (XXX) XXX-XXXX
Project #: P1 Project Description: Project 1 Data
Test # Test Name Test Description Container # Container Description Container Parameter
T1 Test 1 Test Data C1 Container Data C1 Parameter
T1 Test 1 Test Data C2 Container 2 Data C2 Parameter
T2 Test 2 Test 2 Data C1 Container 1 Data C1 Parameter
T2 Test 2 Test 2 Data C3 Container 3 Data C3 Parameter
Project #: P2 Project Description: Project 2 Data
Test # Test Name Test Description Container # Container Description Container Parameter
T1 Test 1 Test Data C1 Container Data C1 Parameter
T1 Test 1 Test Data C2 Container 2 Data C2 Parameter
T2 Test 2 Test 2 Data C1 Container 1 Data C1 Parameter
T2 Test 2 Test 2 Data C3 Container 3 Data C3 Parameter
You Can Add 3 groups.
1 Group:Client
In this group u can add client description etc.
In the Same way other 2 groups
2 Group:Project
3 Group:Test
This Will Display the Data the format you Needed.
heres a table, the time when the query runs i.e now is 2010-07-30 22:41:14
number | person | timestamp
45 mike 2008-02-15 15:31:14
56 mike 2008-02-15 15:30:56
67 mike 2008-02-17 13:31:14
34 mike 2010-07-30 22:31:14
56 bob 2009-07-30 22:37:14
67 bob 2009-07-30 22:37:14
22 tom 2010-07-30 22:37:14
78 fred 2010-07-30 22:37:14
Id like a query that can add up the number for each person. Then only display the name totals which have a recent entry say last 60 minutes. The difficult seems to be, that although its possible to use AND timestamp > now( ) - INTERVAL 600, this has the affect of stopping the full sum of the number.
the results I would from above are
Mike 202
tom 22
fred 78
bob is not included his latest entry is not recent enough its a year old! mike although he has several old entries is valid because he has one entry recently - but key, it still adds up his full 'number' and not just those with the time period.
go on get your head round that one in a single query ! and thanks
andy.
You want a HAVING clause:
select name, sum(number), max(timestamp_column)
from table
group by name
HAVING max( timestamp_column) > now( ) - INTERVAL 600;
andrew - in the spirit of education, i'm not going to show the query (actually, i'm being lazy but don't tell anyone) :).
basically tho', you'd have to do a subselect within your main criteria select. in psuedo code it would be:
select person, total as (select sum(number) from table1 t2 where t2.person=t1.person)
from table1 t1 where timestamp > now( ) - INTERVAL 600
that will blow up, but you get the gist...
jim