How to run Logical Test in Tableau when one column has multiple rows - tableau-api

The first column only has one row while the second column has three rows that correspond to the first row of the first column. For exemple, something like this.
Is there a way to run a logical test where if any of the values in the second column pass the test, I get a 1 and if none of the values in the second column pass the test, I get a 0.
Thank you for your help!

Yes, you can do this, using LODs and simple boolean formula. Please give a more specific example of what you want to do and you can have a formula that'll do it.

Related

Use the bin binary on a per-ticker basis

For two tables each with datetime and ticker symbol columns, how can we achieve the functionality of the binary function bin within each ticker group. That is, instead of returning the latest index from the entire left-table prior to the time of each right-table row, for a given right-table row it should return the latest index from the left-table amongst only the rows of the same ticker symbol as the right-table row.
My first thought would be to add a per-group index in the left-table, apply bin on each ticker group for it’s group-index and then use the unique (ticker,group-index) pair to find the index on the full left-table. However, I am not sure how to implement this or if this is the best way to achieve the desired functionality.
Could you give some sample inputs and desired output?
This sounds like something you can solve with aj
Check https://code.kx.com/q/ref/aj/ for details

Function to call the Name of a column in TABLEAU

I have a problem with Tableau.
I have a Dataset with some rows and some columns. I want to write a IFELSE structure where
The IF condition is that the Value of special field(fixed by a row and a column) is equal to the header of a column (it is every time equal to one name(header) of the different columns).
So to summarize: one value is every time equal to the name of a column and to find the column shall be the if-structure
Does someone know if there is a function to call the name (header) of a column? I didn't find it
Here is an small example, in which the Calculated_function choose the right price according to the Barcode. Everything in the first raw, is the header_name of the column below. enter image description here
Best regards
Jonas
You can work like this.
I created a sample dataset as given by you
Step-1: Connected With data in tableau. Clicked all columns having price (4 here), pivoted them so that they look like this..
Step_2: Create calculated_field like this
if [Barcode] = [Barcode_c]
then [Price] END
Step3: Filtered out null values from calculatedField and got a view like this which can be tweaked as per liking.

COUNTIF based on three conditions using OFFSET and MATCH

Please see example screengrab
I would like to populate cell M2. Firstly to match K2 (Taylor) against column headers C1:I1 looking at the results in the column C2:C32. I would like to find the amount of times "a" appears in C2:C32 where Type (Column B) = "r".
So the result would be 3 (Reynolds, Maggio & Hamilton).
As you can see I've managed to populate Column R with totals without comparing against Type (Column B) but am having great difficulty understanding how to extend the comparison, intentionally without the use of helper columns/rows.
Any help would be greatly appreciated.
Since you have to depend on 2 columns, you will have to use COUNTIFS. Without being dynamic, the formula for M2 would be:
=COUNTIFS($B$2:$B$32,"r",$C$2:$C$32,"a")
^------------^ ^------------^
1st Condition 2nd Condition
To make it dynamic, only the second column needs to be changed:
=COUNTIFS($B$2:$B$32,"r",OFFSET($B$2:$B$32,0,MATCH($K2,$C$1:$I$1,0)),"a")
Your total's formula could be simplified to this also (keep the range as it is instead of manually putting it as 32 rows high for instance):
=COUNTA(OFFSET($B$2:$B$32,0,MATCH($K2,$C$1:$I$1,0)))

add extra column value to a column sum

I have the following issue: I have a report that uses a Dataset as its datasource. The dataset has two tables, one would be the main table, say Employee, and the second table is EmployeePaycheck, so an employee can have several paychecks. I can compute the sum of a column in the second table, say paycheckValue, but what I can't seem to do is also add to this computed field the value of some additional fields in the Employee table, such as ChristmasBonus or YearlyBonus, to see how much the employee was paid at the end of the year.
Without knowing more information on this it will be difficult to answer, but I'll give you a couple things to look for.
First, I would make sure that the fields are of a similar type that will allow for a summary. For example, if one is a string then a summary wouldn't be able to be done without casting or convertingthe value to a number. I'm assuming that the fields are probably number or decimal columns so that is probably not the case.
I'd also check to make sure that none of the values that you are trying to sum are null. I haven't tested this, but I believe that it will not sum correctly if one of the rows has a null value. In this scenario you should just be able to use a formula field to check for the null and if the field is null return 0 instead. Then you can use the formula field in your calculations instead of the field itself.
If neither of these are the case please provide a little more info how you are computing the fields and what is happening when you do it.
Hope this helps.

Retrieving value from previous row in calculated column based on condition

I am working on data in Spotfire. The table has 4 columns:
RowID
StudID
IMT
Date
I am trying to insert a calculated column in Spotfire to get the date from the previous row for a specific StudID. The date should not be filled for first entry for a specific StudID since it does not have a previous row.
Please refer to the image for details:
This will be a calculated column using the OVER function, along with Intersect, Previous and the First aggregation.
First([Date]) OVER Intersect(Previous([Date]), [StudID])
It reads: over the intersection between (group of) the previous (to the current row) dates (which are the same) and the Student ID's (the same as the current row), give me the first row of that group. In your example, it will only ever return one date for that group, but the formula needs to be able to handle what happens if there are multiple rows. You may also need to think about whether this will happen in your data and what you're going to do about it. I.e.
StudID Date
124-639 6/12/2018
124-639 6/12/2018
124-639 6/14/2018
Building off of JasonJ's answer, it looks like his solution ran into issues when the dates of different StudIDs overlapped with one another.
So I was seeing something along the lines of this:
StudID, Date, Result
A, 10/1/2014,
A, 10/10/2014, 10/1/2014
A, 10/17/2014, 10/10/2014
B, 10/20/2014,
A, 10/21/2014,
B, 10/22/2014,
B, 10/24/2014, 10/22/2014
I created a weird workaround by adding another Calculated Column.
I doubt this is the IDEAL way to do this (I'd bet there's a better OVER function, but I couldn't identify it right off), but it looks like it's working.
First Calculated Column (Named [CalcRank]):
Rank(Concatenate([StudID],Year([Date]),If(DayOfYear([Date])<10,"0",""),If(DayOfYear([Date])<100,"0",""),DayOfYear([Date])))
Second Calculated Column:
Max([Date]) OVER (Intersect(Previous([CalcRank]),[StudID]))
Please note, you may have to pad your StudID with 0s to make sure it orders properly, like I did with the Date column.