Updating Column value based on another column value in Spotfire - pie-chart

I wish to create a drop down menu in Spotfire using 5 values.
Col1, Col2, Col3, Col4, Col5
where Col1,Col2,Col3,Col4 and Col5 are column headers in my data sheet.
I am creating a Pie Diagram visualization.
Now, based on my selection Col1,Col2,Col3,Col4 and Col5, I wish to select another column in the Color by: property for the pie.
For example: If I select Col1 then I should get "Col1 Complete" value in Color by: property for the pie. If I select Col2 then I should get "Col2 Complete" value in Color by: property which is another column in the data set.
I was able to create a drop down list using Property Control with the Col1-Col5 values in the list. However, I am unable to handle second part where based on my selection of Col, I need the Color by: property value to change to "Col Complete"
Please advice. Thanks

you can do this with a Document Property:
create a Drop-down list Property Control in a Textarea
under Set property value through: choose Column selection, then choose the correct data table
click New to create a String Document Property called PieColorBy with a starting value of Col1.
open the Properties dialog for the visualization you want to change and access the Colors page
set a Custom Expression like [${PieColorBy} Complete]. notice that Complete is not in quotes.
change the drop-down list to test

Related

SSRS Parameter to select a column name on value which to filter the dataset

I need to allow my user to select a column name and its value from a parameter (or two params) to filter the result.
I have a text parameter with a few column names that are listed in my dataset
Column1, Column2, Column3. Each of those columns has only two values 1 and 0.
I would love some help in getting an idea how to filter my dataset based on the column name listed in the parameter and a selected value (1 or 0)
I assume it has to be related to a dynamic sql but, not sure how to incorporate that in either the WHERE clause or the actual dataset filter.
Thanks for any points guys!! :)
In the tablix you can use the filter section to set the criteria
col1 = param1.This will only select the rows that match the value of the parameter.
https://www.mssqltips.com/sqlservertip/2597/dataset-and-tablix-filtering-in-sql-server-reporting-services/

Two filters on one column with respect to each other

I would like to filter my data source by itself. In SQL it is just INNER JOINNING a table by itself.
For example,
SELECT table1.*
FROM table1 INNER JOIN (SELECT id FROM table1 WHERE variable = ‘X’ AND value = 1) q1 ON table1.id = q1.id
WHERE table1.variable = ‘Y’
As you can see I want to present only the variable which equals ‘Y’ with respect to variable =’X’ and value=1.
I can also write it like this,
SELECT *
FROM table1
WHERE variable = ‘Y’ AND id IN (SELECT id FROM table1 WHERE variable = ‘X’ AND value = 1)
I am using a long data file which means my primary key is 'id' and 'variable' together. So, I want all the variable = ‘Y’ data to be presented only if the 'id' has variable = ‘X’ AND value = 1. How do I translate this process in Tableau dashboard?
Any suggestions on how to do it without inner joining the data source by itself? I tried the inner join way but my data is very large which resulting in too much processing time and it makes all the other processes extremely slow.
First, just point your data source at table1 without any other changes. Plain and simple.
Second, back on a worksheet, select the id field in the datapane and right click to create a set. Choose the all radio button on the general tab of the set dialog pane, and then switch to the condition tab. Define the set via the formula max(variable = 'x' and value = 1). Call your set something meaningful like ids_having_an_X1. This will create a set of ids that have at least one data row matching your condition. Think of it as a list of ids that could go inside a SQL IN (...) clause if that helps
Now you can use your set on the filter shelf to only include those ids in the query, or in calculations, or on other shelves.
To get the effect of your where clause, put variable on the filter shelf choosing only the value 'Y'

How to add two or more column in third column in SQL server 2008

For Example
Roll No, Name, Maths, English, Total(Maths+English)
You can use a computed column. Assuming columns Maths and English are a numeric type, you can do like so:
ALTER TABLE [MyTable] ADD Total AS Maths + English;
Once created, you access the column (read only, obviously) as you would any other column, i.e.
select English, Maths, Total from [MyTable];
SELECT Roll No, Name, Maths, English, Maths+English AS TOTAL
FROM [YOUR TABLE]
You need to assign the Total column a function
go to the table in design view mode, then click on Total column (I assume
you already have this column, if not create it first, and then click on it in design view)
then from column properties expand 'Computer Column Specification'
then in forumula field write:
(Maths+English)

Get the value of visible column of JasperReports Server input control?

I have a report in JasperReports Server 5.2.0, in this report I have two input control
first one is:
COUNTRY (value column- COUNTRY_ID, visible column- COUNTRY_NAME)
and another one is
STATES (value column- STATE_ID and visible column - STATE_NAME).
These two parameters I am passing to the report, now at the end of the report I want to show the input parameter selection value so user can see what he has selected. But I am not able to get the visible values of parameters. I can print only value column value.
So my question is there any way to print the visible column values of input control in reports?
Till now , Visible Columns are not passed,where Value Columns are passed to Jrml File in Jasper.
To answer you question There is a way to print the visible column values.
It can be done using Sub-queries, by using 'Value Column' passed to the JRML file.
Then add the subquery to your main query and it`s done!!
In the above scenario You can display
State Name
SELECT States.STATE_NAME from States WHERE state_id = $P{STATE_ID} - If it is Single Select input control
SELECT GROUP_CONCAT(States.STATE_NAME) from States WHERE state_id = $X{IN,state_id,STATE_ID} - If it is Multi-Select input control
Country Name
SELECT Country.COUNTRY_NAME from COUNTRY WHERE country_id= $P{COUNTRY_NAME} - If it is Single Select input control
SELECT GROUP_CONCAT(Country.COUNTRY_NAME) from COUNTRY WHERE country_id = $X{IN,state_id,STATE_ID} - If it is Multi-Select input control
Suppose this your main query where Country and State are missing..
SELECT
`id`,
`product-id`,
`name`,
`description`,
`branch`,
`stock`,
`price`
FROM
`products`
WHERE
`name` LIKE "%car%"
The modified query will looks like..
SELECT
`id`,
`product-id`,
`name`,
`description`,
`branch`,
`stock`,
`price`,
(SELECT States.STATE_NAME from States WHERE state_id = $P{STATE_ID}) as state,
(SELECT Country.COUNTRY_NAME from COUNTRY WHERE country_id=P{COUNTRY_NAME}) as country
FROM
`products`
WHERE
`name` LIKE "%car%"

Copy selected query fields name in Mysql Workbench

I am using mysql workbench (SQL Editor). I need copy the list of columns in each query as was existed in Mysql Query Browser.
For example
Select * From tb
I want have the list of fields like as:
id,title,keyno,......
You mean you want to be able to get one or more columns for a specified table?
1st way
Do SHOW COLUMNS FROM your_table_name and from there on depending on what you want have some basic filtering added by specifying you want only columns that data type is int, default value is null etc e.g. SHOW COLUMNS FROM your_table_name WHERE type='mediumint(8)' ANDnull='yes'
2nd way
This way is a bit more flexible and powerful as you can combine many tables and other properties kept in MySQL's INFORMATION_SCHEMA internal db that has records of all db columns, tables etc. Using the query below as it is and setting TABLE_NAME to the table you want to find the columns for
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='your_table_name';
To limit the number of matched columns down to a specific database add AND TABLE_SCHEMA='your_db_name' at the end of the query
Also, to have the column names appear not in multiple rows but in a single row as a comma separated list you can use GROUP_CONCAT(COLUMN_NAME,',') instead of only COLUMN_NAME
To select all columns in select statement, please go to SCHEMAS menu and right click ok table which you want to select column names, then select "Copy to Clipboard > Select All statement".
The solution accepted is fine, but it is limited to field names in tables. To handle arbitrary queries would be to standardize your select clause to be able to use regex to strip out only the column aliases. I format my select clause as "1 row per element" so
Select 1 + 1 as Col1, 1 + 2 Col2 From Table
becomes
Select 1 + 1 as Col1
, 1 + 2 Col2
From Table
Then I use simple regex on the "1 row per select element" version to replace "^.* " (excluding quotes) with nothing. The regex finds everything before the final space in the line, so it assumes your column aliases doesn't contain spaces (so replace spaces with underscore). Or if you don't like "1 row per element" then always use "as" keyword to give you a handle that regex can grasp.