How to create a drop down or multiple select filter in dashboard that will filter all worksheets? - tableau-api

I have null and non-null values in my dataset. I would like to create a drop down which will consist of -Display All, Null or Non-Null values. This should filter the dataset so that all worksheets in the dashboard are filtered out based on it. How shall I proceed?

A parameter will help you accomplish this.
Create... > Parameter > String > List > ["All", "Non-Null", "Null"]
From there, create a calculated field which references the parameter.
If [Parameter] = "Non-Null" Then
(If IsNull([Nullable Field]) = False Then 'Show' Else 'Hide' End)
ElseIf [Parameter] = "Null" Then
(If IsNull([Nullable Field]) = True Then 'Show' Else 'Hide' End)
Else 'Show'
End
Finally, place the newly created calculated field on filter and select only 'Show.' To filter all worksheets, right click on the filter and select Apply to worksheets > All using related datasource or specific sheets of your choosing.

Related

Count if "YES" in 1 field or another in Tablean

I am trying to create a calculated field in tableau that will count if one field OR another contains 'yes' - and then add the YES's together as a value.
I have tried CASE WHEN, IF, COUNTIF but I am having trouble as I have to have the OR in the calculated field.
Here is my last attempt that also failed:
COUNTIF([M-CROSSC (Cross Country)]) = 'YES' OR ([W-CROSSC (Cross Country)])= 'YES' THEN '1' END
Try this. Put the if statement inside the count().
COUNT(IF [M-CROSSC (Cross Country)] = 'YES' OR ([W-CROSSC (Cross Country)]= 'YES' THEN '1' END)
edited to remove extra ')' after each dimension.

Nested if else Condition in Crystal report

I have a .rpt file , with a view datasource . I have four parameter which i use in filtering the selection. I have written my selection formula like below.
if ({?actype} <> "All") OR ({?actype} <> "All") OR ({?collectorname} <> "All") OR ({?batchno}<> "All") Then
(
if {?actype} <> "All" Then
{CollectorPerformance.accountType} = {?actype};
if {?collectorname} <> "All" Then
{CollectorPerformance.realname} = {?collectorname};
if {?batchno} <> "All" Then
{CollectorPerformance.batchno} = {?batchno}
and
{CollectorPerformance.clientid} = {?clientid}
and
Date({CollectorPerformance.paymentdate}) >= Date({?from})
and
Date({CollectorPerformance.paymentdate}) <= Date({?to})
)
My issue with the formula, above is that it does not filter by realname and actType. I understand the reason is because the key word "and" is missing . however, it filters the batchno correctly> please how do i make it filter by the remaining two if's ? any help would appreciated.
A selection formula has to be one long valid boolean statement, which is, I think, what you were already suggesting when you say the "and is missing". So in order to fix the first half, you just need to translate those statements into one simplified boolean statement instead of individual statements (those that end in a ';').
({?actype}="All" or {?actype}={CollectorPerformance.accountType})
and
({?collectorname}="All" or {?collectorname}={CollectorPerformance.realname})
and
({?batchno}="All" or {?batchno}={CollectorPerformance.batchno})
...
For each parameter, a user can either select "All" or enter a specific value to filter by. If "All" is selected, that particular portion of the statement (The part that looks like {?Parameter}="All") will evaluate to True and no filtering will be done. Otherwise, only records matching the entered parameter value will return True.

How to write custom function in crystal report to be used for record selection

I am confused in writing custom function in crystal report to fetch record using record selection.
When we create formula in record selection it will add where clause in the generated SQL-Query on the basis of parameters used. Now i want to write the custom formula, which will extract the record pro-grammatically :
Even i have written a function :
Function (stringVar st)(
stringVar selection;
if (st <> 'ALL') then (
selection = st;
)
else(
//In this case the user select only single value, it will fetch the result to that //particular column value in the table.. otherwise it leaves that particular row..
selection = "multiple selection";
)
)
Now the code to use the custom function in record selection using select expert would be :
if(myfunction({?parameter1}) <> "ALL") then
(
// what code should i write to select that particular record...
if(myfunction({?parameter2})) <> "ALL" ) then
(
//do selection from the previously selection of rows which have this parameter
if(myfunction({?parameter3}) <> "ALL") then
(
//do selection from the previously selection of rows which have this
//parameter
)
else (//do something else)
)
else (//do something else)
)
else (//do something else)
Thanks, in advance.
You don't need a custom function for this. Assuming that you have two string parameters, ry:
// assumes you have a parameter value of 'All Countries' w/ a value of '0'
( '0' IN {?CountryCodes} OR {table.CountryCode} IN {?CountryCodes} )
// assumes you have a parameter value of 'All Regions' w/ a value of '0'
AND ( '0' IN {?RegionCodes} OR {table.RegionCode} IN {?RegionCodes} )

How to filter rows with null values in any of its columns in SSRS

I want to filter out the output without rows containing null values or blank columns. I am using SQL Server 2012 there is no option named 'Blank' as in SS2005 where I can filter the rows. I also tried following expression but it gives me error or not showing correct output
=IsNothing(Fields!ABC.Value)!= True
=Fields!ABC.Value = ''
Please suggest the solution.
Pull up the tablix or group properties
Switch to "Filters"
Add a new filter
Set the expression to:
=IsNothing(Fields!YourFieldHere.Value)
Set the type to "Boolean" (see screenshot below) otherwise you'll get a "cannot compare data of types boolean and string" error.
Set the value to false
This works for filtering both rows and groups.
We should use the isNothing method in the Expression, change the Text to Boolean
and then Value will be "True"
for example:
Expression
=IsNothing(Fields!TestA.Value)<>True
(Expression type should be Boolean)
Operator
=
Value
=True
Edit the SQL query, so that it will not return NULL values in the column to group on, but let it return a dummy value; for example: ISNULL(columnA, 'dummy')
In the column group definition add a filter: ColumnA <> 'dummy'.

Change Group Name in Crystal Reports to non-Database Value using Formula

I am looking to change the group names in a crystal report to a specified text value not located within the database.
e.g. i have a 'status' field that can either be 'i' or 'a'. I would like these to display as 'inactive' or 'active' in the group headings. The code i currently have in the 'Use a formula as group name' is:
stringvar newGroupName;
if (groupname = "I") THEN newGroupName:= "Inactive" ELSE
if (groupname = "A") THEN newGroupName:= "Active" ELSE
newGroupName:= groupName;
newGroupName
However this says i am passing too few arguments for the groupName reserved word.
Have looked on the net but have not found anything for defining non database names using the groupname function. Any help greatly appreciated.
Just to add, I always add a standard formula to the formula list to calculate the group names :
if {table.field} = 'I' then
'inactive'
Else if {table.field} = 'a' then
'active'
Else
'unknown'
Then in the group name formula in the group expert I refer to the formula like {MyGroupName}
This makes it much easier and quicker to edit the names but also will not be lost if you edit the group field (very useful if you have a large amount of code).
Make sure you pick fields from the window they will appear like {table.field} etc
There is no need for variable here just do something like:
if {table.field} = 'I' then
'inactive'
Else if {table.field} = 'a' then
'active'
Else
'unknown';