Tableau Parameter Selection - tableau-api

I have a parameter and a calculated field
Parameter - "Hierarchy" (which is a string - '1', '2', '3')
Calculated Field - "Division" (which is based on the Hierarchy chosen)
Case 1 display '' (nothing)
Case 2 and 3 show Dimension A
My question - when I select a value 'X' from Division, when the parameter is set to 2 or 3. The value 'X' remains, when I switch to 1. I would like this to default to the 'All' values.
I don't have data for 'X' at level 1 hierarchy. So, my graphs shows nothing, which isn't good.
Does anyone know how to script this to default to 'All' when I revert selection to '1' (and I don't mean the string 'All', I mean the ALL values selection used in filtering.
Thanks,
gemmo

Assuming you are using quick filters, try setting your quick filter to display "Only Relevant Values" instead of "All Values in Database". I think that's the default setting, so that's likely not the complete solution to your problem -- but its something you can check quickly before diving deeper.
Another thing to check - what data source are you using? Some data sources have limitations, in particular, the MS Jet engine used for MS Access, Excel and text files apparently doesn't handle sets in filters (among other limitations). Tableau announced at their 2013 customer conference that they planned to replace the Microsoft Jet Engine in Tableau 8.2 (again -- I'm not sure that's your issue here)

I don't think tableau have this level of programmability. In short - can't be done at the moment. Research didnt bear any fruit

I was able to do this but it took an extra calculated field to make it work. Inside your parameter add the Value "All" and Display as "All".
Then create a calculated field with a case statement that returns 'All' for every value in your field's set. Something like this for you:
CASE Parameter
WHEN 1 THEN 'All'
WHEN 2 THEN 'All'
WHEN 3 THEN 'All'
END
I named it _All. Then add to or create a T|F calculated field to add to your filter pane. Add this to the field.
[_All] = [Parameter]
You should see then be able to select "All" in your parameter control and have it show all values.

Related

Why does grafana display NaN for values that are clearly integers?

I created a SQL query that counts the number of servers running test jobs on a specific Jenkins server at a specified time. I'm trying to chart it on Grafana but for some reason, it's displaying the value as NaN.
The data source is a MySQL server. I'm running Grafana version 8.1.5. I went on the server (phpMyAdmin) to check the results of the query and I can see numbers.
When we look at the grafana chart/panel, the bars on the chart look like it matches the values, but the chart shows NaN instead of the value.
What setting do I need to change so that it can print the numeric value on the chart instead of displaying NaN?
EDIT: Looks like I didn't include enough info to my question.
Here's the query that's used, although, I don't know how feasible it is to include the tables with data to demo the issue:
SELECT COUNT(DISTINCT(tb_name)) as val, jenkins FROM (
SELECT
hw.collected_date AS mytime,
hw.jenkins AS jenkins,
hw.name AS tb_name
FROM hw_report as hw LEFT OUTER JOIN jenkins_owner jo
ON hw.jenkins = jo.jenkins
WHERE jo.org IN ('Enterprise Readiness')) as y
WHERE mytime = '2021-12-03 00:00:00'
GROUP BY jenkins
HAVING count(distinct(tb_name)) > '0'
Here are screenshots of my panel. The "Show values" setting is set to "Always", which II assume should show the values.
One thing I noticed is when I hover over the bar, it shows
COUNT(DISTINCT(name_cnt))
instead of a numeric value. Not sure if this is indicative of anything. I checked other charts in the dashboard that someone created and their bars either have a numeric value or it's just a column name (like name_cnt)
Sorry I'm a noob and didn't know what to configure, look up, or mention in my question. I accidentally came across the answer.
So it seems like I need to select something under the "Transform" tab for the panel. Calculation needs to be "Total" instead of "Count" and I need to hide the fields specified in my SQL query and show the "Total"

Group data based on different size

I am trying to make a report in which I need to show data based on Width groups. Below is an example of data & the required output. I'm unable to make a group which can give this required output. If someone can help please.
The easiest way to accomplish your grouping needs for this data set would be to create a new Formula Field that evaluates the values of the Width data field for each record to determine which group the record belongs within, then do the grouping on this new formula field.
You formula field will look like this.
Select {WIDTH}
Case 400 to 600 :
"G1"
Case 601 to 849:
"G2"
Case 850 to 1049:
"G3"
Default :
"Default text or error message text goes here"
You will likely need to adjust the integer values I'm used in the Case statements to evaluate the WIDTH field. The text that goes into the Default case is up to you. In fact, if it works logically with your needs, you could eliminate the Default case entirely, as it is not required. However, it is good practice to ensure the Switch statement always returns a value, even if that value is text to indicate that something unexpected occurred. This allows your users to easily recognize a bit of a data that may be out of range for the grouping of the report so the report can be modified or the data can be corrected, whichever is the most appropriate action.
The other 3 columns in your required output appear to just be counting the number of records within each group that have a diameter within a range. To get this output you can use Running Total Fields with a Type of summary of Count and then use the range of values in the Evaluate section. The Reset section will be set to On change of group evaluating the group created by the formula field above. You will want to put a sort order on the diameter field though.

Tableau Mixed Data

I've been tasked to set up a Tableau worksheet of counts of data (ultimately to create percentages) where the contrived incoming data looks like the following.
id fruit
1 apple
1 orange
1 lemon
2 apple
2 orange
3 apple
3 orange
4 lemon
4 orange
The worksheet needs to look something like the following:
Count of ids
2 Lemons
2 No lemons
I've only been using Tableau for about 4 hours, so is this doable? Can anyone point me in the right direction?
The data is coming in from a SQL Server database in a format that I can control if that helps contribute towards a solution.
Alex's solution based on sets are very good for this scenario, but I would like to show that LODs can be more flexible if you need to extend your solution to include more categories.
for the current scenario, create a calculation with below formula and create text table using COUNTD(Id)
{FIXED [Id]:IF MAX([Fruit]='lemon') THEN 'Lemon' ELSE 'No Lemon' END}
Now for the extension part, you are considering below list where you want to count IDs with Lemon, Apple and others. Since no double counting of Ids are allowed, categorization will follow the order. (This kind of precedence will be a headache without LODs)
Now you can change your calculation as below:
{FIXED [Id]:IF MAX([Fruit]='lemon') THEN 'Lemon'
ELSEIF MAX([Fruit]='apple') THEN 'Apple'
ELSE 'No Lemon or Apple' END}
Now your visualization automatically changes to include the new category. This can be extended for any number of fruits.
This is a good use for a set.
In the data pane on the left sidebar, right click on the Id field and create a set named "Ids that contain at least one lemon" (or use a shorter less precise name)
In the set definition dialog panel, define the set by choosing "Use all" from the General tab, and then on the Condition tab, define the condition by the formula max([Fruit]="lemon")
There are many ways to think of a set, but the most abstract is just as a mathematical set of Ids that satisfy the condition. Remember each Id has many data rows, so the condition is a function of many data rows and uses the aggregation function MAX(). For booleans, True is treated as greater than False, so MAX() will return True if at least one of the data rows satifies the condition. By contrast, MIN() is True only if ALL (non-null) data rows satisfy the condition.
Once you have a set that separates your ids into Lemon scented Ids and others, then you can use that set in many ways - in calculated fields, in filters, in combination with other sets to make new sets, and of course on shelves to make visualizations.
To get a result like your question seeks, you could put your new set on the Row shelf, and put CNTD(ID) on the text shelf or columns shelf. Make sure you understand why you need count distinct (CNTD) instead of SUM([Number of Records]) here.
BTW, the LOD calculation { fixed [Id] : max([Fruit]="lemon") } is effectively the same solution.

Reporting services cascading parameter not working

I want the report to pick default date time values based on a location parameter the user picks, but the problem is that the date time parameters don't update when the user picks a different location. I made sure to put the location parameter above the date time parameters but it is still not functioning as I expect, what am I doing wrong here?
Unfortunately this is "by design".
Microsoft Connect - SSRS - default not refreshed for cascading parameters.
Posted by Microsoft in 2007: "As described, this is not
a bug. We do not re-evaluate the default value for a subsequent
parameter unless the selected value is no longer in the valid values
list. We do not know whether the current value was specifically
requested by the user or it is there because of the default. You could
make a case to have control over this behavior through some sort of
property but it is currently working as designed."
I think this is a bug in SSRS. But Microsoft have closed the issue. Please log onto connect and vote this to be fixed if it is affecting you too
Microsoft Connect - Your feedback improving Microsoft products.
Workaround / hack is here: Boyan Penev - SSRS Cascading Parameters Refresh: Solved.
However the hack only works if the dependent parameter has a LIST of valid values, and other users report that it only works for the first dependent parameter.
If the dependent parameter is free-form entry or a date, the hack cannot be used at all.
Consider putting your datetime values in a dataset with logic based on the location parameter
SELECT CASE #Location WHEN 'Paris' THEN GETDATE()+10
WHEN 'Berlin' THEN GETDATE()+11
WHEN 'New York' THEN GETDATE()+8
ELSE GETDATE() END as DefaultDate
Then set the date parameter default value to this dataset.
Unfortunately, SSRS does not refresh cascading parameters once they have been set. Other than reloading the report, the only way that I am aware of is to create a custom UI using the ReportViewerDialog.
I have found that if you use a stored procedure to render the child parameter, by passing in the parent selection, the dataset will get refreshed
I've been having the same issue, and realized it was a simple mistake causing this issue. Posting here for OP and anyone else searching for this issue.
You need to ensure that all parameters, in SSRS, are set to the correct value field, not the display field. You can replicate the cascading parameter issue that many have identified by simply selecting a "Name" field in the parameter default values instead of the "Value" field requested. This will populate the drop down correctly but nothing will be selected, and the cascade will stop. It may then appear as though the cascading parameters are not refreshing because of the Closed be Design issue.
In SSRS In Report Data tab, right click parameter and select
Parameter Properties.
Select Default Values.
Ensure that Value Field is set to the correct value for your sproc, not the value that you present to report users.

How can I conditionally group items in Crystal Reports?

I have a report that is currently separated into two reports, and I'd like to merge them.
Basically it boils down to this:
I ask the user if they want to have a page break for each Property, if they answer yes, I sort/group by Property and then I sort by X
If the user answers no, I want to just sort/group by X
I've tried suppressing the initial Grouping if the user answers No, but it still sorts accordingly (not how I want it to).
How can I do this without keeping it in two reports?
Instead of suppressing the grouping field, try setting it to an empty string "". I was just working on a report last week that was very similar. Even if 'no grouping' was selected, the report was still being grouped by some unknown default. In the formula grouping field, I found that if 'no grouping' was selected the field was not getting set at all. Once I changed it to set the field to an empty string, the report generated as expected.
Are you grouping or sorting? If you do not use the group header/footer it is basically the same as sorting and you should simply use the record sort.
In general, to conditionally group fields you would use formulas. For this to work the fields in question need to be returned as the same type: number, string, date, etc. In your case it sounds like the first grouping formula would be like this...
//{?break_by_property} would be the parameter value to control the page break
if {?break_by_property) then
{the_property_field}
else
"" //any static value of the same type as {the_property_field}
now go the "new page before" formula for that group header and enter this boolean formula (groupnumber is a special keyword)...
{?break_by_property} and groupnumber > 1
then add a record sort for X.