Expression to hide tablix in ssrs - ssrs-2008

I wish to set the visibility for the tablix based upon the value selected in parameter.
The scenario is I have four tablix week, month, quarter, year. I have created a parameter "timeline" and in the parameter i have added week month quarter year as specified values in available values option
I have used the following queries but i cant hide those tablix if I select corresponding value from the timeline parameter (Even if I select or deselect any value in the parameter all the four tablix are displaying)
=IIF(Parameters!Timeline.Value = "Month",TRUE,FALSE)
=IIF(Parameters!TimeLine.Label.Equals("Year"),True,False)
What expression would fix this issue?
Here is the screenshot of the Report screen

You need to apply the Visbility on the Column Group. (MTD, QTD, YTD, etc) and not on the Taxlib itself.
Additionally, for the MTD for example, the hidden expression Parameters!Timeline.Value <> "Month"
Hope this helps.

You can use below code by following below note:
Set visibility false of all your tablix so that when you will select all
=SWITCH
(Parameters!Timeline.Value = "week",TRUE,FALSE,
Parameters!Timeline.Value = "month",TRUE,FALSE,
Parameters!Timeline.Value = "quarter",TRUE,FALSE,
Parameters!Timeline.Value = "year",TRUE,FALSE
)

Related

Filter multiple views with different dates on one parameter issue

I have two metrics: rep_id, user_id
I have three dimensions: rep_onboard_date, user_application_date, user_enrollment_date
I created a parameter called "Launch Date", which is a date that equals 1/1/2018. Note that I have data going back a few years before that.
I have three views:
1) columns = month(rep_onboard_date), rows=cntd(rep_id)
2) columns = month(user_application_date), rows=cntd(user_id)
3) columns = month(user_enrollment_date), rows=cntd(user_id)
I would like to create a single filter on the dashboard- to filter all, pre "Launch Date" and post "Launch Date".
I tried creating three calculated fields according to http://kb.tableau.com/articles/howto/creating-a-filter-for-start-and-end-dates-parameters so I created:
Onboard_Date = [rep_onboard_date]>=[Launch Date]
Application_Date = [user_application_date]>=[Launch Date]
Enrollment_Date = [user_enrollment_date]>=[Launch Date]
But then I can only add one or the other (or both) as filter- which isn't what I am looking for.
Note that adding these into one filter with an "or" statement doesn't work because when setting filter=True I still get data before the Launch Date.
Any help is greatly appreciated!
My suggestion is add one filter and add these filter conditions as if statements in calculated fields, This will be like processing inside tableau after fetching data from database instead of working directly on database.
Incase if you want to apply as filters then take 3 sheets and apply filters individually and combine sheets in dashboard.
Edit-----------------------------------------------------------------
create 3 calcualted fields:
1st calculated field:
if [rep_onboard_date]>=[parameter.Launch Date]
then table.field
2nd Calculated filed
if [user_application_date]>=[parameter.Launch Date]
then table.field
3rd Calculated Field
if [user_enrollment_date]>=[parameter.Launch Date]
then table.field
one condition is launch date should be parameter then create one more calculated field with parameter using lauch date an select true by placing on filter:
table.launch date> parameter.launch date

Add default start and end date to crystal report parameter

I have a crystal report where i have a date parameter called range that i want to default the min and maxdate values. So in the edit parameter dialog under value options section there are options for "start" and "end" which i want to be mindate and maxdate respectively. The problem i am trying to solve is i want all records to return if the user does not enter a value for the range. Is this even possible? Thanks in advance for any advice.
I am running latest version of crystal reports
Easy way I think is of using 2 parameters instead of one, That is one parameter for start date and other for End Date.
Add a default value None for both and if user doesn't want to select any value then ask to select None
Now change your record selection formula as
if {?start date} = "None" and {?End date} = "None"
then
//Don't pass any date filter
else
//Add date filter as per parameter selection
An easy way could be to just enter min and max dates manually and make the parameter not optional.
A more elegant way is to check whether the parameter has a value and only filter your records if it has. Put something like the below in your record selection formula:
if hasvalue({?range}) then {yourdatefield} in {?range} else true
If the parameter range has a value then it is used as filter. If it hasn't a value the term will evaluate to true meaning no records will be filtered.
Yes it is possible make the parameter as optional. By default it will bring all the data, if user not select any thing.

How to control number of bars in a bar chart based on date selection by user in Tableau

I have a date parameter which has a week split.
When I select Week 4 I need 4 bars(one for each week viz Week1, Week2, Week3, Week4) in a chart with sum of sales data.
When I select Week 3 I need 3 bars(one for each week viz Week1, Week2, Week3) in a chart with sum of sales data
and so on ...so when I select Week 1, i will have just one bar in my chart.
I tried using DATEDIFF with last() but I am not able to control the number of bars in the bar chart
Here is what works for me:
Create a parameter based on your date field, call it timeframe (or whatever), Data Type: Date, allowable values: all
Create a calculated field with the following formular
If [Date] < [Timeframe] then [Value] ELSE null END
with [Date] being your date field and [Value] being the original measure you want to display
Use the new calculated field instead of the original measure in your graph
Right click on the created parameter and choose " Show parameter controls"
Now when you change the date in the parameter controls, the amount of bar charts will adjust that only the weeks up to that date are displayed.
It should look like this:
Edit:
If you wanted an "All" option, you could go to the parameters settings, choose "List" as the "allowable Values" and add the values from your date field.
You then just create an additional item manually with the Value of "01/01/2011" or any other date far in the future) and Display as "All".
However this will only work if you have static data! If you update your source and new, more recent values were added, they will not appear in the list since you specified explicitely which values to be available.
I also realized the following:
If you do it like I explained, you will be able to choose particular days, that might lead to different graphs for different days of the same week. Ie if I choose tuesday orfriday of the same week, I will have different sized bars although the sales of the whole week stay obviously the same. If that is alright for your use case, go for it. Otherwise you should create another calculated field with DATETRUNC("week", [date]) and use that for the paramter and calculation. With that you can only choose the week, so no matter which day of a week you choose the bar will always have the same height.

expression to hide tablix based on condition

We need to hide tablix in ssrs report based on boolean value from dataset, currently when we use below expression it picks only first record value which is incorrect.
expression :
=IIF(First(Fields!DisplayRecommendations.Value, "Comments") ="True", false, true)
is there any way we could use where condition and get the correct value ?
I was trying to use hidden property of a tablix rather we need to use textbox hidden propery inside tablix.
If your dataset returns multiple rows you can summarize it in one at SQL Query level.
select count(*) as Display from Comments
where DisplayRecommendation = 'False'
Then in the textbox hidden property check if the dataset result was greater than 1
=Iif(First(Fields!Display.Value, "Comments") > 0,True,False)
Note Comments dataset will return one value.
Let me know if this was helpful.

Crystal Reports and Adding values

I am using Crystal Reports XI and I'm trying to add a particular column if one column or another column is set to one.
Here is the current preview:
Username (GROUP 1)
MONTH (GROUP 2)
DATE SUBJECT TOTAL_TIME
End of group 2
End of group 1
Now I want to add the values in total_time if one of the two hidden fields contain 1 (true).
I tried using sum() function but it didn't work as it added all the times together.
I'm still new to Crystal Reports and I tried searching on google but nothing came up similar to what I need.
Any help would be greatly appreciated.
One alternative that I can suggest, You can use Parameter fields on your report.
Do the calculation on Code behind and set the calculated sum to parameter field on Page_Load event of Crystal Report page.
This parameter field will be used to display the sum on report page.
Please check this link to see
-How to create Parameter Fields:
http://devlibrary.businessobjects.com/BusinessObjectsXIR2/en/en/CrystalReports_dotNET_SDK/crsdk_net_doc/doc/crsdk_net_doc/html/crtsktutorialscrvparametersdiscretecreatingreport.htm
-How to set values in Parameter Fields:
http://msdn.microsoft.com/en-us/library/aa289936(v=vs.71).aspx
Your best option will be use "Running totals" by this way you can control the flow by keeping a condition to sum when the required column is 1.
Did you think about small trick? You wrote: I want to add the values in totaltime if one of the two hidden fields contain 1 (true).
Under these circumstances you can calculate helper field Total_Time_Conditional using formula:
Total_Time_Conditional = IIf(HiddenField1 = 1 or HiddenField2 = 1, 1, 0) * Total_Time.
This will multiply Total_Time
by 1, if any of hidden fields is 1
by 0, if both hidden fields are 0
Calculating Sum(Total_Time_Conditional) will give you expected result.