I am working on SSRS reporting and want to summarize (sum) the amount field and narrow the output of the report. As you can see on the below table, the data source has a date field which is unique for each row which make it difficult for me to summarize the output. I want the date field only for filtering purpose, I don't want to show the date data in the details of the report. But since the date field is there in the data which is returned by the query, and I am trying to filter the report using date field, I couldn't be able to summarize it (sum the amount field).
Any Idea?
current data set on SSRS returns the following result
id item date amount
1 item 1 1/1/2015 1200
1 item 1 1/2/2015 1200
1 item 1 1/3/2015 1200
1 item 2 1/4/2015 100
1 item 2 1/5/2015 100
1 item 2 1/6/2015 100
My need (when I filter the report with: where date > = 1/1/2015 and date <= 1/6/2015)
id Item Amount
1 item 1 3600
1 item2 300
Since you are summarizing the data in SSRS you just the group level not the detail section.
Create a Group by Item
Delete the detail section by clicking on the tablix.
Put the expression of the textbox =SUM(Fields!Amount.Value)
The other way to handle this scenario is to modify your query and group by in query by the item while adding the Date filter in the where clause.
Related
I am learning ssrs reporting and dashboard.
I have a requirement, i am having Field 1 and Field 2 in my report which is having if condition inside and get the values.
I need to have Field 3 (total of Field 1 records) Field 4 (total value of Field 2 records), How can i calculate the total records value and display it in field 3 and Field 4?
Field 1 Field 2 Field 3 Field 4
10 30
20 40
I need to use Field 3 and Field 4 in my dashboard and calculate the percentage
any help on this would be greatly appreciated.
thanks
do you expect something like below?? I am not sure If I understand your req correctly.
In my case I have added extra column Field3 and this will hold sum of amount.
Is this what you want??. If yes then
Is there a way to use an Over and Intersect function to get the average sales for the first 3 periods (not always consecutive months, sometimes a month is skipped) for each Employee?
For example:
EmpID 1 is 71.67 ((80 + 60 + 75)/3) despite skipping "3/1/2007"
EmpID 3 is 250 ((350 + 250 + 150)/3).
I'm not sure how EmpID 2 would work because there are just two data points.
I've used a work-around by calculated column using DenseRank over Date, "asc", EmpID and then used another Boolean calculated column where DenseRank column name is <= 3, then used Over functions over the Boolean=TRUE column but I want to figure the correct way to do this.
There are Last 'n' Period functions but I haven't seen anything resembling a First 'n' Period function.
EmpID Date Sales
1 1/1/2007 80
1 2/1/2007 60
1 4/1/2007 75
1 5/1/2007 30
1 9/1/2007 100
2 2/1/2007 200
2 3/1/2007 100
3 12/1/2006 350
3 1/1/2007 250
3 3/1/2007 150
3 4/1/2007 275
3 8/1/2007 375
3 9/1/2007 475
3 10/1/2007 300
3 12/1/2007 200
I suppose the solution depends on where you want this data represented, but here is one example
If((Rank([Date],"asc",[EmpID])<=3) and (Max(Rank([Date],"asc",[EmpID])) OVER ([EmpID])>=3),Avg([Sales]) over ([EmpID]))
You can insert this as a calculated column and it will give you what you want (assuming your data is sorted by date when imported).
You may want to see the row numbering, and in that case insert this as a calculated column as well and name it RN
Rank([Date],"asc",[EmpID])
Explanation
Rank([Date],"asc",[EmpID])
This part of the function is basically applying a row number (labeled as RN in the results below) to each EmpID grouping.
Rank([Date],"asc",[EmpID])<=3
This is how we are taking the top 3 rows regardless if Months are skipped. If your data isn't sorted, we'd have to create one additional calculated column but the same logic applies.
(Max(Rank([Date],"asc",[EmpID])) OVER ([EmpID])>=3)
This is where we are basically ignoring EmpID = 2, or any EmpID who doesn't have at least 3 rows. Removing this would give you the average (dynamically) for each EmpID based on their first 1, 2, or 3 months respectively.
Avg([Sales]) over ([EmpID])
Now that our data is limited to the rows we care about, just take the average for each EmpID.
#Chris- Here is the solution I came up with
Step 1: Inserted a calculated column 'rank' with the expression below
DenseRank([Date],"asc",[EmpID])
Step 2: Created a cross table visualization from the data table and limited data with the expression below
I was wondering if anyone had a good solution to trying lookup a value against a range of values in a fuzzy lookup transformation.
By "range of values" I mean either a date range such as start and end dates in the lookup table or comparison range such as a high and low value of house numbers compared to the exact house number in a record.
Or if there is solution how to solve fuzzy lookup against only valid values by condtion.
Iam using ssis 2008
Example:
My sales data example:
ID Product Quatity date
1 Product1 1 1.2.2015
2 Produc?t1 1 1.2.2015
3 Produt1_ 1 10.7.2015
My price list
ID Name Price ValidFrom ValidTO
1 Product1 10 1.1.2015 28.2.2015
2 Product1 11 1.3.2015 null
My sales data are kind of dirty (sources are various) - that's why I want to use FUZZY lookup.
I want to fuzzky lookup againts my price list but only against valid prices.
So after lookup result should look like this
ID Product Quatity date Price
1 Product1 1 1.2.2015 10
2 Produc?t1 1 1.2.2015 10
3 Produt1_ 1 10.7.2015 11
But if I use fuzzy I cannot specify the condition before I use fuzzy lookup.
Thanks in advance,
Martin
I am Trying to do a Matrix Style Report , where the Rows get Populated from the Query.
Can we Give Values in the Column Field(These are Row Values from the Query) and the data gets Populated from the Query itself.
Why I want to do this is, the query does not show the row if the Value that I want to display in the column field on the report is Null. And Hence in return cannot Display it on the report if the Query itself Does not have the value.
Now there are No values for any member in the Group, the transfers field will not show up. But it has show with a value 0 in all the columns with Row Members.
EDIT:
My query returns a table like this . Parameter: 'YEAR'
Group Group_Items EMP_ID Status
Group1 Alpha 1 Continuing
Group1 Alpha 2 Continuing
Group1 Alpha 6 Continuing
Group1 Beta 8 First Time
Group1 Beta 11 Continuing
Group1 Gamma 14 First Time
Group1 Gammma 15 First Time
Group1 Gamma 10 First Time
Group1 Zeta 12 Continuing
Group1 Zeta 23 Continuing
Group1 Zeta 44 Continuing
Group1 Zeta 56 First Time
So I want to know how we can put this in the BI and count(Emp_ID) according to First Time, Transfer and Continuing. There is transfer value sometimes , but have to show it all the time and if no values come up we have to show it as 0
You could check for NULL/non-existent values in the transfer cell by using an expression like:
=IIf(IsNothing(Sum(Fields!Transfer.Value))
, 0
, Sum(Fields!Transfer.Value))
This will display 0 if there is are no values in that row/group or they're all NULL.
More logic can be added to the first section of the IIf statement if required.
compliment of the day.
Based on the previous feedback received,
After creating a Ticket sales database in MS Access. I want to use a single form to Query the price of a particular ticket at a particular month and have the price displayed back in the form in a text field or label.
Below are sample tables and used query
CompanyTable
CompID CompName
A Ann
B Bahn
C Can
KK Seven
- --
TicketTable
TicketCode TicketDes
10 Two people
11 Monthly
12 Weekend
14 Daily
TicketPriceTable
ID TicketCode Price ValidFrom
1 10 $35.50 8/1/2010
2 10 $38.50 8/1/2011
3 11 $20.50 8/1/2010
4 11 $25.00 11/1/2011
5 12 $50.50 12/1/2010
6 12 $60.50 1/1/2011
7 14 $15.50 2/1/2010
8 14 $19.00 3/1/2011
9 10 $40.50 4/1/2012
Used query:
SELECT TicketPriceTable.Price
FROM TicketPriceTable
WHERE (((TicketPriceTable.ValidFrom)=[DATE01]) AND ((TicketPriceTable.TicketCode)=[TCODE01]));
In MS Access, a mini boxes pops up to enter the parameters when running the query. How can I use a single form to enter the parameters for [DATE01] and [TCODE01]. and the price displayed in the same form in a textfield (For further calculations).
Such as 'Month' field equals to input to [DATE01] parameter
'Ticket Code' equals to input for [TCODE01] parameter
Textfield equals to output of the query result (Ticket price)
If possible, I would like to use only the Month and Year in this format MM/YYYY.The day is not necessarry. How can I achieve it in MS Access?
If any question, please don't hesitate to ask
Thanks very much for your time and anticipated feedback.
You can refer to the values in the form fields by using expressions like: [Forms]![NameOfTheForm]![NameOfTheField]
Entering up to 300 different types of tickets
Answer to your comment referring to Accessing data from a ticket database, based on months in MS Access)
You can use Cartesian products to create a lot of records. If you select two tables in a query but do not join them, the result is a Cartesian product, which means that every record from one table is combined with every record from the other.
Let's add a new table called MonthTable
MonthNr MonthName
1 January
2 February
3 March
... ...
Now if you combine this table containing 12 records with your TicketTable containing 4 records, you will get a result containing 48 records
SELECT M.MonthNr, M.MonthName, T.TicketCode, T.TicketDes
FROM MonthTable M, TicketTable T
ORDER BY M.MonthNr, T.TicketCode
You get something like this
MonthNr MonthName TicketCode TicketDes
1 January 10 Two people
1 January 11 Monthly
1 January 12 Weekend
1 January 14 Daily
2 February 10 Two people
2 February 11 Monthly
2 February 12 Weekend
2 February 14 Daily
3 March 10 Two people
3 March 11 Monthly
3 March 12 Weekend
3 March 14 Daily
... ... ... ...
You can also get the price actually valid for a ticket type like this
SELECT TicketCode, Price, ActualPeriod AS ValidFrom
FROM (SELECT TicketCode, MAX(ValidFrom) AS ActualPeriod
FROM TicketPriceTable
WHERE ValidFrom <= Date
GROUP BY TicketCode) X
INNER JOIN TicketPriceTable T
ON X.TicketCode = T.TicketCode AND X.ActualPeriod=T.ValidFrom
The WHERE ValidFrom <= Date is in case that you entered future prices.
Here the subquery selects the actually valid period, i.e. the ValidFrom that applies for each TicketCode. If you find sub-selects a bit confusing, you can also store them as query in Access or as view in MySQL and base a subsequent query on them. This has the advantage that you can create them in the query designer.
Consider not creating all your 300 records physically, but just getting them dynamically from a Cartesian product.
I let you put all the pieces together now.
In Access Forms you can set the RecordSource to be a query, not only a table. This can be either the name of a stored query or a SQL statement. This allows you to have controls bound to different tables through this query.
You can also place subforms on the main form that are bound to other tables than the main form.
You can also display the result of an expression in a TextBox by setting the ControlSource to an expression by starting with an equal sign
=DLookUp("Price", "TicketPriceTable", "TicketCode=" & Me!cboTicketCode.Value)
You can set the Format of a TextBox to MM\/yyyy or use the format function
s = Format$(Now, "MM\/yyyy")