I want to use one parameter for date and another one for time in my reports as shown below.
Start Time [16/01/2012][12.00 am]
Can anyone help me regarding that?
Sure it is a multiple step process:
Set up a variable of TEXT as 'DATE' as the variable value and prompt
Set it's 'Default Values' in the left pane to be '1/16/2012'
Set up a variable of TEXT as 'TIME' as the variable value and prompt
Set it's 'Default Values' in the left pane to be '00:00'
Set up a dataset, 'AvailableDateTime' to combine the two into a legitimate datetime field:
SELECT CAST(#Date + ' ' + #Time AS DateTime) AS Datetime
Set up a third variable of DATETIME to be 'DATETIME' as the variable value and prompt.
Set up this variable to use 'AVAILABLE VALUES' on the left pane of properties to be 'Get values from a query'. Use the dataset from step 5.
You now have set up a separate field for data and time.
Further consideration to avoid user input error. You may wish to tie the first variables to be selectable ONLY FROM values you set in available values or from a query. The problem being if a user fat fingers the date or time it will not run as the system is only trying to combine two strings and make a datetime out of it. You may wish to list values directly from a query from the getgo.
EDIT FOR CHANGING FIRST TWO VARIABLES:
You may set the first variable as datetime which gives the end user a calendar.
You can set a second dataset up to get available times for an end user:
declare #time table ( tm int)
declare #cursor int = 0
while #cursor <= 23
Begin
insert into #time values (#cursor)
set #cursor += 1
End
select cast(CAST(tm as varchar) + ':00' as time) as HourOfTheDay
from #time
Setting your second variable to get values from a query that is made in step 2 directly above.
You should now be able to put the values together as above.
As I said in my comment, SSRS does not allow you to have separate parameters for Date and Time.
It has only one parameter Date/Time.
As I see you have two options.
Add a text parameter and consider that as time. You could then do
some validation depending on what tech you are using.
Another way to solve this would be creating a list of possible
values. You select Integer type, for instance and then create a list
of Available Values. (see images)
Related
Self-taught at SPSS here. Need to know the appropriate syntax to recode four DATE variables into one, based on which would be the latest date. I have four DATE variables in a dataset with 165 cases:
wnd_heal_date
wnd_heal_d14_date
wnd_heal_d30_date
wnd_heal_3m_date
And each variable may or may not contain a value for each case. I want to recode a new variable which scans the dates from all four and only selects the one that is the latest and puts it into a new variable (x_final_wound_heal_date).
How to use the SELECT IF function for this purpose?
select if function selects rows in the data, and so is not appropriate for this case. What you can do is this instead:
compute x_final_wound_heal_date =
max(wnd_heal_date, wnd_heal_d14_date, wnd_heal_d30_date, wnd_heal_3m_date).
VARIABLE LABELS x_final_wnd_heal_date 'Time to definitive wound healing (days)'.
VARIABLE LEVEL x_final_wnd_heal_date(SCALE).
ALTER TYPE x_final_wnd_heal_date(DATE11).
This will put the latest of available date values in the new variable.
In Tableau Desktop, I have 2 different periods as per below:
and I want the result to be 20 --> Value (29) - Value (28) = 20
Thank you,
You should create a calculated field calculated_value and compute using 'Table (down)'.
sum(Value) - lookup(sum([Value]), -1)
Hope this helps!
I had a similar issue I was trying to resolve and managed to use parameters for added flexibility.
The calculation by Prem only gives you the difference based on the previous value.
In case you wanted it to be adjusted between different periods. You can use parameters to help with this.
Make Period a 'Date' datatype and create 2 parameters:
Params (Start Date/End Date): Type 'Data', List and pull values from Field 'Period'
Create a calculated field called 'Numerator': if([Period] = [Start Date]) Then [Value] else 0 end
Create a calculated field called 'Denominator: if([Period] = [End Date]) Then [Value] else 0 end
Create a calculated field called '%Difference': Sum([Denominator])-Sum([Numerator])
This gives flexibility for different periods and allows users to toggle which value they want and to see the difference accordingly.
Alternatively, you can see a link I found helpful as well: https://community.tableau.com/thread/225030
I have a basic bar graph and i want to add a reference line expresion to it.
However when i add the line it is taking the wrong value.
Sample data
SaleDate DaysToPay
01/02/2015 60
01/03/2015 60
01/06/2015 60
01/07/2015 30
As you can see the days to pay drops to 30 for the most recent date, this needs to be the value the reference line uses.
Currently the expression I have tried i:
=[DaysToPay]
Which gives the value of 60.
In SQL I would do the following, but this doesn't work in a QV expression for a reference line.
SELECT s.*
FROM sales s
INNER JOIN
(SELECT DaysToPay, MAX(SaleDate) AS MaxSaleDate
FROM sales
GROUP BY DaysToPay) groupDays
ON s.DaysToPay = groupDays.DaysToPay
AND s.SaleDate = groupDays.MaxSaleDate
Assuming your data is loaded in as a date field, you can force Qlik to use the value associated with the latest date in your reference line with:
=concat({$<SaleDate={"$(=max(SaleDate))"}>} DaysToPay)
I use the concat function above, however in the situation where there is only ever one record per day, the function is irrelevant as you will only ever have one value to concat. In a situation where you have multiple values per day, you'll need to decide what logic you want to use to keep one of the values, or aggregate them somehow (i.e. average).
I have 2 multi-value parameters in my report. When we generate the report using only one of them a problem arises. If I select a value for parameter 1 and keep parameter 2 unselected I get an error:
Please select a value for the parameter Param2
This happens even if I check "allow blank value" in the parameter's properties.
In addition: is there a way to make a set a parameter to be enabled/disabled based on a another parameter's value? For example:
if I create another parameter having values Param1, Param2;
if I select a value for Param1 the report will be generated based only on values selected in Param1, disabling or disregarding Param2
The short answer is no.
My workaround for this scenario is to fiddle with the Dataset driving the Available Values list for Param2. You need to set it up so that when the particular Param1 value is selected, the only row that will match will be a dummy row (e.g. 'N/A'). This might involve a UNION ALL to generate that dummy row.
I use the same dataset for Default Values so that the dummy row will be automatically selected when the Param1 value is selected.
You then need to cater to that dummy Param2 value in the other datasets that refer to Param2, e.g. SELECT ... WHERE ( #Param2 = 'N/A' OR Column2 = #Param2 ).
In my SSRS report there are 2 parameters called DataSourceIDList and ReporterIDlist.
DataSourceIDList : is a drop down list and this will populate based on SQL query.
ReporterIDlist : is a drop down list and this will populate reporters based on selected Datasourceid from DataSourceIDList and this is also a SQL query.
both parameters are optional fields but when i am running the report i am getting error called "Please select value for DataSourceID" but i set the property for that parameter as allow NULL values
and same problem for ReporterIDlist also.
Please suggest your suggestion....
Thanks in advance...
I think that SSRS will not allow you NULL value if parameter have datasource.
Trick that I do when I need all values that is: I change data source for parameters that is in list have
null, or ( 0) value, and option select ALL, and after that I set default value to null so users do not have to touch parameters before it call it
Something like this,
Select 1,null as ValueOfParam,'All values' as TextOfParam
union all
select 2,id,name from myDatasourceThatHaveParamValues
order by 1,name
to verify date, you can use this method too:
make two rectangle; insert table/matrix in first rectangle
in second rectangle insert msg like
"Selected Date is not valid, please select correct date"
or "Start Date should be less less than End Date"
put appropriate msg, and make condition in 1st rectangle where all tables/matrix is there
iif( Parameters!StartDate.Value < Parameters!EndDate.Value,false,true)
in second rectangle where Error msg is inserted write this:
iif( Parameters!StartDate.Value < Parameters!EndDate.Value,true,false)