SSRS - How to show date on Horizontal Axis - reportingservices-2005

I want to put the date on the X (Horizontal-Axis).
Simple count of sales by day.
Current chart:
I see how to turn off the legend. Might also be good to make bars the same color. But I don't see what else to do to get the date. I did try the labels tab, and put in an expression "=Fields!WebOrderDate.Value", but that didn't change anything.
Here are my current settings:
My SQL:
select CONVERT(date, WebOrderDateTime) as WebOrderDate,
Count(*) as Count
from VendorTrackingViewRpt
where PONum is not null and WebOrderDateTime is not null
group by CONVERT(date, WebOrderDateTime)
order by CONVERT(date, WebOrderDateTime)

I don't have SSRS available to me right now, but I think you should put the WebOrderDateTime under Category Groups instead of Series Groups.

Related

How to create chart with multiple series in Oracle Apex

I have a bar chart that it works fine, but the chart use just one series for all bars and all bars have same color. What should I do for creating different series for each records of my query?
This is my query:
select customeTable.firstname||' '||customeTable.lastname as fullName, customeTable.sumHour as sumHour
from (
select sum(projActivity.ACTIVITY_HOUR) as sumHour, users.FIRST_NAME as firstname, users.LAST_NAME as lastname
from SITA_PROJECT_TASKS_ACTIVITY projActivity
inner join SITA_PROJECT_TASKS projTask on projTask.ID=projActivity.TASK_ID and projTask.PROJECT_ID=:P39_PROJECT_ID
inner join SITA_USERS users on users.ID=projActivity.CREATOR_ID
where
(:P39_FROM_DATE is null or projActivity.ACTIVITY_DATE>=:P39_FROM_DATE)
and (:P39_TO_DATE is null or projActivity.ACTIVITY_DATE<=:P39_TO_DATE)
group by users.FIRST_NAME,users.LAST_NAME
) customeTable
If you have a column in your query that can be used to derive the name of the series, you can set that column as the name of the series. Demo application can be seen here.
You'd do exactly what you said: add another series. How? Right-click the chart region name and select "Create series":
Every series can have its own query, or they can share the region's source - it depends on you. Fill other required properties and you should have several series on the same chart.

How can I display Row Number in Cross-Tab?

I'm looking for a way to display row number in my cross-tab.
I tried searching online for the answer on how to do it but I haven't found anything useful.
So I'm turning to the good people on Stack Overflow.
The reason that I want to do this, if it's even possible, is because many clients in the company I started working at asked to have a row number in the cross-tab.
I am using Visual Studio 2013 and Crystal Reports.
So is there any basic ( easy ) way to do this in Crystal Reports?
For example, I have a cross-tab that displays unit of measure and amounts.
https://imgur.com/a/lOjCq
But I would like my cross-tab to be like:
Amount
1. Total -38
2. KG
3. kut 9
4. LIT. 4
5. m -32
6. proc
7. KoŠ¼ -19
Please keep in mind that I only started working with Crystal Reports this week, so this is all new to me. And the cross-tab in the picture is just a random one I made to explain what I need.
Thank You in advance.
In order to show Row Number in your CrossTab you will need to first put Row Number in the Stored Procedure that sends data to your report.
In order to understand it better i will first show you how my data looks before i add a Row number(Pic 1).
Code:
select
a.S_ID as ID,
osn.sifra as BasicGoodsCode,
osn.naziv as BasicGoods,
null,
a.RobaSifra as GoodsCode,
a.Roba as Goods,
a.Detalj as Detail,
a.DetaljDodatak as DetailsAddon
from NP_Stavke s
left join RobaGrupe osn on osn.id = s.RobaId
left join #A a on a.S_ID = s.Id
order by BasicGoodsCode, ID
Pic 1: As you can see I have 3 different Ids for BasicGoods which means that I have 3 Rows in my CrossTab
Columns ID, BasicGoodsCode and BasicGoods are going to be Rows in my CrossTab.
Values from column DetailsAddon are going to be my columns in CrossTab.
Columns GoodsCode, Goods and Detail are going to be values in my CrossTab.
Column Pieces is not important.
Now that you know how everything looks we can start with adding a Row Number to our CrossTab.
Step 1:
First thing that you need to do is to add a Row number in table in your stored procedure.
To do this I used DENSE_RANK()
depending on your data you might need to use ROW_NUMBER() or maybe even something else. I used DENSE_RANK() because I needed my row number to change once S_ID changes.
Code:
select
a.S_ID as ID,
DENSE_RANK() OVER (ORDER BY osn.sifra, s.Id asc) as BasicGoodsRowNo, // THIS IS ADDED
osn.sifra as BasicGoodsCode,
osn.naziv as BasicGoods,
null as Pieces,
a.RobaSifra as GoodsCode,
a.Roba as Goods,
a.Detalj as Detail,
a.DetaljDodatak as DetailsAddon
from NP_Stavke s
left join RobaGrupe osn on osn.id = s.RobaId
left join #A a on a.S_ID = s.Id
order by BasicGoodsCode, ID
Lets take a look at how our data looks now(Pic 2)
As you can see we added a Row Number that changes when Id changes.
IMPORTANT: Row Number has to be ether Integer or Decimal in the DataTable that you are using in your report if it's not it will not work correctly.
Step 2:
We've done the 'hard' part now it's time to put Row number in our CrossTab.
When you create a CrossTab or when right click CrossTab and then click on 'Cross-Tab Expert...' it will open a window like this one and in it in the Row section you will insert your Row Number Column(in my case and as you can see in the code above the name of my Row Number Column is 'BasicGoodsRowNo').
Step 3:
Since you don't want to show only the Row number in the report left click on your Row and then click on 'Group Options...'(Pic 4)
Once the new window appears click on 'Options' tab then check the 'Customise group name field' then click on 'Use a formula as group name' and then on 'x-2'(Pic 5)
Step 4:
Enter a formula like this one:
toText( {myTbl.BasicGoodsRowNo}, 0, "" ) + '. ' + {myTbl.BasicGoodsCode} + ' ' + {myTbl.BasicGoods}
Of course your formula will not be exactly like mine since you will not have the same columns as I do. The only part of this formula that you HAVE to have is toText( {myTbl.BasicGoodsRowNo}, 0, "" ) where instead of {myTbl.BasicGoodsRowNo} you will put your row number column. You will need toText since if you dont have that and you want to show a String after your Row Number it will give you an error because RowNumber is an integer field.
GJ YOU ARE ALL DONE AND IT WASN'T THAT HARD WAS IT
How My CrossTab looks once RowNumber is added
Now there is a way to simplify this process and that is:
Step 1:
In your stored procedure create 2 columns. One will show Row Number and the other will show Value that will be displayed as CrossTab row.
Code:
select
a.S_ID as ID,
DENSE_RANK() OVER (ORDER BY osn.sifra, s.Id asc) as BasicGoodsRowNo, // RowNumber
CONVERT(varchar(10), DENSE_RANK() OVER (ORDER BY osn.sifra, s.Id asc)) + '. ' + osn.sifra + ' ' +osn.naziv as BasicGoods, // Value that will be displayed in CrossTab Row
null as Pieces,
a.RobaSifra as GoodsCode,
a.Roba as Goods,
a.Detalj as Detail,
a.DetaljDodatak as DetailsAddon
from NP_Stavke s
left join RobaGrupe osn on osn.id = s.RobaId
left join #A a on a.S_ID = s.Id
order by BasicGoods, ID
As you can see Column BasicGoodsRowNo did not change and will still display the same values as before and I have deleted the clumns BasicGoodsCode and BasicGoods and replaced them with this
CONVERT(varchar(10), DENSE_RANK() OVER (ORDER BY osn.sifra, s.Id asc)) + '. ' + osn.sifra + ' ' +osn.naziv as BasicGoods,
The BasicGoods column will show BasicGoodsRowNo + BasicGoodsCode + BasicGoods.
Step 2:
Step 2 is the same as before.
Step 3:
Once you click on your row and on 'Group Options' go to 'Options' tab again then check the 'Customise group name field' check box again and after that instead clicking on 'Use a formula as group name' click on 'Choose from existing field' and from a combo box select the column you want to show as Row Value in your CrossTab. In my Case that is 'BasicGoods' column (Pic 7).
I used the first method since depending on what user decides I may not show CrossTab at all and I may not show BasicGoods but if you only have CrossTab in your report you can use the second, shorter and easier, method.
If you have any questions feel free to ask.

How can i hide a row in interactive grid based on some column value?

I have an interactive grid with a list of records and lets say it has a date column. Now i only want to show those records or make only those records editable whose month in that date column is equal to the current month on page load. Now i know that a dynamic action can be created with execute javascript code as the option. But what would be the actual code to do it? I tried to access the grid with this
var grid = apex.region("emp").widget().interactiveGrid("getViews", "grid");
Then i can use the grid.model._data to get the records and loop through it and check the date column values and verify if it is current month or not, but after checking i don't know as to set the css for that particular row as {display: none;}. Any help would be appreciated. Thanks.
Try this:
1 - Create a dynamic action in your interactive grid on the column that you want
disable
Event: Row Initialization [Interactive Grid]
Selection Type: Columns
Region: Your grid region
Columns: Your column to disable or enable
2 - On Client Side Condition:
Type: JavaScript expression
Javascript Expression:
//Suppose there is a function (getMonth)
//that returns the number of the month (1..12) in a date string;
//you can do this expression.
getMonth($(this.triggeringElement).val()) != ((new Date()).getMonth() + 1)
3 - True action
Disable
Selection type: Columns
Columns : The column to want disable or enable
Example: https://apex.oracle.com/pls/apex/f?p=145797:8
The column "CREDIT LIMIT" is disable when the value is 3000
i only want to show those records (...) whose month in that date column is equal to the current month on page
load
As interactive grid's source is a SELECT statement, why wouldn't you include a WHERE clause which says something like this:
where trunc(date_column, 'mm') = trunc(sysdate, 'mm')
Yes, I know - possible performance impact (index on DATE_COLUMN not being used) and stuff, but that's just the general idea. Could be further improved if it turns out to be OK.
[EDIT, after seeing the comment]
No problem in changing the WHERE clause:
where date_column >=
case when to_number(to_char(sysdate, 'dd')) <= 5 then trunc(add_months(sysdate, -1), 'mm')
else trunc(sysdate, 'mm')
end

VisualStudio 2010 - How do you display only YEAR in a chart?

This is the code I used in my dataset. The result is as shown in the image.
The plan is to display the YEAR without month, day or time. Is this feasible?
SELECT t.Name AS Territoryname,
p.LastName AS SalesPerson,
c.CardType AS PayType,
s.OrderDate,
s.TotalDue
FROM Sales s
JOIN Person p
ON s.SalesPersonID=p.BusinessEntityID
JOIN CreditCard c
ON c.CreditCardID=s.CreditCardID
JOIN Territoryt
ON t.TerritoryID=s.TerritoryID
There are a number of ways to achieve this. The easiest, is to calculate a year value directly in your dataset, and then use this field in your chart. This is a simple matter of adding the following code to the select part of your dataset:
select
...
s.OrderDate,
YEAR(s.OrderDate) AS [OrderYear], -- This is the new field
s.TotalDue
from
...
Alternatively, you can create an expression that does the same thing, either as a calculated field in your dataset, or directly in the chart as the category field.

OBIEE using the same folder/fact twice aggregating on both

I know the exact SQL I would need to write to retrieve the results I'm looking for from the Oracle BI tool, however, as I am new to Oracle BI I am struggling to find a way to reproduce the same results. I realize that the ultimate answer largely depends on the BI data model and that takes a lot more communication than a question on Stack Overflow will allow, so I'm looking for more generic how-to answers than a specific definitive answer for my scenario.
Perhaps the SQL will help for starters:
select "All"."DT", ("LessThan5Mins"."Count" / "All"."Count") * 100
from
(
select to_char(m."EndDateTime", 'YYYY-MM') "DT", count(*) "Count"
from "Measurement" m,
"DwellTimeMeasurement" dtm
where dtm."MeasurementBase_id" = m."Id"
group by to_char(m."EndDateTime", 'YYYY-MM')
) "All",
(
select to_char(m."EndDateTime", 'YYYY-MM') "DT", count(*) "Count"
from "Measurement" m,
"DwellTimeMeasurement" dtm
where dtm."MeasurementBase_id" = m."Id"
and m."MeasValue" <= 300
group by to_char(m."EndDateTime", 'YYYY-MM')
) "LessThan5Mins"
where "All"."DT" = "LessThan5Mins"."DT";
The purpose of this is to return the percentage of dwell time records that were less than or equal to 5 mins (300 seconds).
I have a fact that represents the "MeasValue" field in the above query.
All attempts I've made to reproduce the dual result set nature of the above query in BI have failed.
Is the above possible in OBIEE and if so, how might I achieve this?
I'm assuming that you have imported the Measurement (M) and DwellTimeMeasurement (DTM) tables into the physical layer of the RPD, specified the join on DTM.MeasurementBase_id = M.Id, and then brought them both through to the presentation layer.
If so, then you could start building this query in Answers on the criteria tab by dragging in M.EndDateTime and any OBIEE measure column from DTM, for example DTM.Amount. Edit the formula for the DTM.Amount column:
Filter the column by clicking the filter button shown in blue below.
In the following dialog box double click on M.MeasValue and then select "is less than or equal to" and type 300 in the Value text box. Click OK twice and your column formula should now look something like this:
FILTER(DTM.Amount USING (M.MeasValue <= 300))
Now wrap this with COUNT():
COUNT(FILTER(DTM.Amount USING (M.MeasValue <= 300)))
This will give the count of records with M.MeasValue <= 300. You could rename this column to be "LessThan5Mins". Click OK to save the new formula. Now drag in the DTM.Amount column again but this time only perform a COUNT():
COUNT(DTM.Amount)
This will give you the count of all dwell time records. You could rename this to "All". Finally drag in the DTM.Amount column one last time and edit it's formula again. This is where you will calculate the percentage with a formula similar to the following:
COUNT(FILTER(DTM.Amount USING (M.MeasValue <= 300))) / COUNT(DTM.Amount) * 100
So ultimately you will have four columns with the following titles and formulas:
TITLE FORMULA
----- --------
EndDateTime M.EndDateTime
LessThan5Mins COUNT(FILTER(DTM.Amount USING (M.MeasValue <= 300)))
All COUNT(DTM.Amount)
% LessThan5Mins COUNT(FILTER(DTM.Amount USING (M.MeasValue <= 300))) / COUNT(DTM.Amount) * 100
Note that including the EndDateTime column takes care of grouping the records. Also, to match your original query you would only need the EndDateTime and % LessThan5Mins columns (you could hide or exclude the other columns) but I wanted to demonstrate for you the process of filtering column values in OBIEE.

Resources