I have a simple data set something like this one.
data = [ {column:'a',value:10},
{column:'a',value:2},
{column:'a',value:5},
{column:'b',value:12},
{column:'b',value:1},
{column:'b',value:8},
{column:'c',value:6}]
I have created a group on top of this data and used in data table which shows something like this
(* considering all the dimension and groups are created at this stage)
Column Value
A 17
B 21
C 6
The real problem comes when I try to filter the data, I have attached a text filter to this. Whenever I try to filter it the records which have value == 0 doesn't not disappear rather it stays showing the value as 0 something like this
Case 1 : The textfilter is filtered with column 'a' the table is showing like this.
Column Value
A 17
B 0
C 0
How do I make the ones with zero value disappear from the table on filter while using groups in the data table ?
I am assuming you are looking for something like the chart build in following link:
dc charts with filtering removing
You can see the source code, they have written a method called "remove_empty_bins". You can also implement something like that.
I hope this answer your question. If you need more help, please create a demo for your problem.
Related
I have a table like this:
a
b
c
1
2
abc
2
3
4.00
note c2 is text while c3 is a number.
When I do
=QUERY(A1:C,"select *")
The result is like
a
b
c
1
2
2
3
4.00
The "text" in C2 has been missed. You can see the live sheet here:
https://docs.google.com/spreadsheets/d/1UOiP1JILUwgyYUsmy5RzQrpGj7opvPEXE46B3xfvHoQ/edit?usp=sharing
How to deal with this issue?
QUERY is very useful, but it has a main limitation: only can handle one kind of data per column. The other data is left as blank. There are usually ways to try to overcome this from inside the QUERY, but I've found them unfruitful. What you can do is just to use:
={A:C}
You can work with filters by its own, but as a step-by-step to adapt the main features of query: If you need to add conditions, use LAMBDA INDEX and FILTER
For example, to check where A is not null:
=LAMBDA(quer,FILTER(quer,INDEX(quer,,1)<>""))({A:C}) --> with INDEX(quer,,1), I've accesed the first column
Where B is more than one cell and less than other:
=LAMBDA(quer,FILTER(quer,INDEX(quer,,2)>D1,INDEX(quer,,2)<D2))({A:C})
For sorting and limiting an amount of items, use SORTN. For example, you want to sort by 3rd column and limit to 5 higher values in that column:
=LAMBDA(quer,SORTN(FILTER(quer,INDEX(quer,,1)<>""),5,1,3,0))({A:C})
Or, to limit to 5 elements without sorting use ARRAY_CONSTRAIN:
=ARRAY_CONSTRAIN(LAMBDA(quer,FILTER(quer,INDEX(quer,,1)<>""))({A:C}),5)
There are other options, you can use REGEXMATCH and other options, and emulate QUERYs functions without missing data. Let me know!
shenkwen,
If you are comfortable with adding an Google App Script in your sheet to give you a custom function, I have a QUERY replacement function that supports all standard SQL SELECT syntax. I don't analyze the column data to try and force to one type based on which is the most common data in the column - so this is not an issue.
The custom function code - is one file and is at:
https://github.com/demmings/gsSQL/tree/main/dist
After you save, you have a new function from your sheet. In your example, the syntax would be
=gsSQL("select a,b,c from testTable", {{"testTable", "F150:H152", 60, true}})
If your data is on a separate tab called 'testTable'(or whatever you want), the second parameter is not required.
I have typed in your example data into my test sheet (see line 150)
https://docs.google.com/spreadsheets/d/1Zmyk7a7u0xvICrxen-c0CdpssrLTkHwYx6XL00Tb1ws/edit?usp=sharing
I have a google spreadsheet which matches submodules and product. Below is what sheet looks like.
What I want to do is transform this data to matrix such like below.
Can I make it with one function? I want to use it in Mmult function so it would be better matrix without labels.
I cannot catch any ID to get through it. Hope I get good clues to do it. Thanks a lot.
Not quite the result you show from the data sample provided, but I think at least close to what you want:
=query(A2:C5,"select B, sum(C) group by B pivot A")
To get a 0 in the pivot table I added a row in the source data.
I am new to Tableau and I am trying to filter the results in one sheet based on a selection made in another worksheet. Below, I provide a basic outline of the problem in general terms.
Suppose I have a Sheet A and I filter on dimensions C1 and C2. Based on this I get 10 rows of my data (the original data is 100 rows, suppose). Now, I want to display only the values corresponding to these 10 rows in another worksheet B but filtered on a column C3 (not the original columns C1 and C2), i.e., I want to select the 10 different values in Column C3 and show results in sheet B corresponding to these values.
I tried Filter Action but it seems I can create filters based on the filters I have chosen on Sheet A, i.e., C1 and C2. How can I create a filter corresponding to column C3?
Thanks for your help. Please let me know if the question is too general or not clear.
I didn't totally understand your question but will try to help with whatever I understood.
You can create a filter for Column 3 in the second sheet and when you use action filter in Sheet 1 in dashboard it shows the data based on the action filter and also the filter for Column 3 set for sheet 2.
You can also use parameter.Firstly create a parameter for column3. Create a calculated field using that parameter and use the calculated field as input for the graph or table you create in sheet 2.
Refer these links for calculated fields and parameter:
https://www.interworks.com/blog/rcurtis/2016/05/26/tableau-deep-dive-parameters-calculated-fields
https://www.interworks.com/blog/anonymous/2012/03/26/how-create-and-use-parameters-tableau
My data is stored in Oracle and the only way I can run a report with it is using Crystal Reports. I have a set of data that looks like this ,,,,,,,,,,1, or ,1,,,,,,, or ,1,,,,,1,,,,1,. There are more variations.
Each one means a value is true for a record. There are about 54 'ticks/commas' What I want is all records with the one at the X spot. So for one report I may want all records in the 10th spot that have a 1. There may be other times where I want the records where the 1 is after spot 36. I agree it will pull other records but the main once I want is the X spot.
How do I get this? I tried a Like command but that does not narrow the data down far enough. I am familiar with SQL but not Crystal.
Any help would be great. TIA
In Crystal, you might try setting up a Parameter Field to hold a numeric value (1 to 54) then use that in a formula as the Record Selection. You'll be prompted to enter the parameter when you run the report.
In record selection i was initially going suggest the following which would bring back all records with 1 in the 12 spot. But this makes it hard to bring back a range.
split({yourfield},",")[12] = 1
This will bring back the same
instr({#test},"1") = 12
Then for your suggestion above you could use the following to bring back any record if it has a one in any spot after 36
instr({#test},"1") >= 37
As long as there is only one 1 in the field you can use this for other ranges as well.
Actually I don't want to disturb both answerts by Clayton Morris and CoSpringsGuy hence posting my answer.
You need to combine both the solutions to get the desired result.
Create a number parameter and provide either 1 to 57 numbers or keep just a filed to enter desired number.
Now in record selection use the formula given by CoSpringsGuy
if instr({databasefield.column},"1") = {?Inputnumber} --parameter field
then {databasefield.column}
Right now, I am using a filtering scheme which only looks at the data of the 5 or 6 most common entries in the 'Clinic' field. But, there are a handful of other possibilities which might account for a few rows each. They are too inconsequential to include on their own (I am using pie charts and bar charts), but I would like these rows to be accounted for. For this reason, I would like to create an "Other" category which groups these entries together. What is the best way of doing this? I know I can create a calculated column that groups everything aside from the top 5 or 6 in an other category, but I thought there might be a way to keep working with the original column and achieve the same result.
Unfortunately not. In 6.5.x you will have to write a case statement that will specify everything that is not most common to other.
In 7.0.x you can go to insert binned column. Add the bottom you can use values to create a bin. Add the values you want to the bin and call them "Other". Of course if you look at the column created like this, it is a case statement. But it is a whole lot faster than writing it yourself.
Following phiver I came out with this solution in Spotfire 6.5.2:
Add a calculated column
With something like this:
If(DenseRank(Count([Formation]) OVER ([Formation]),"desc")<10, DenseRank(Count([Formation]) OVER ([Formation]),"desc") & " " & [Formation], "10 Other")
Hope that helps.