Tableau -Calculated field for matching values based on criteria in a different column - tableau-api

I am trying to create a calculated field based on three conditions .
I have two columns names " source system names" which has only two values 302 and 202 only and other column name "unique ID have different numerical values .
I want to create a calculated field which will display the data as shown in "calculated field display " column. I need some help to write a logic on this .I have not done something like this before in tableau .Can someone help me out .I have around 0.5 million rows so need a logic that would work for this size of data .
Please refer attach image for a clear picture of what iam doing .
202 RECORD ONLY - when unique ID does not exists in row having source system as 302 .(example row 1,3 and 4)
302 RECORD ONLY - When unique ID does not exists in row having source system as 202.(example row 9,11 and 12)
EXISTS in both 302 and 202 - when unique ID is same for source system names 302 and 202 .(2 and 10 , 5 and 8 and 6 and 7)
Kindly help me to create a calculated field with this logic .
I tried CASE and IF function ,but i was not able to do it .
for easy understanding refer the 4th column in the attached imageenter image description here

If the 'Source System Names' has only 2 values you could create the following calculations to do what you want (assuming all the fields are strings, if they're integers this will still work with some simple changes):
Max: Source System Name
{FIXED [Unique ID]: MAX([Source System Names])}
Min: Source System Name
{FIXED [Unique ID]: MIN([Source System Names])}
Calculated Field Display
IF [Min: Source System Name] != [Max: Source System Name]
THEN 'Exists in Both 302 and 202'
ELSEIF [Max: Source System Name] = '202'
THEN 'Exists in 202'
ELSEIF [Max: Source System Name] = '302'
THEN 'Exists in 302'
ELSE
NULL
END
Hopefully that helps!

Related

Tableau Calculated Field to Display Specific Rows

I'm trying to find a way to display only certain rows of my data based off a very specific criteria. I will try to explain it the best way I can. Let's start with a screenshot here:
Picture of part of the Tableau sheet as-is
What I'm trying to do is create a way to display only the values of "Order: Sales Order #" that have a value filled in for "Item: Connected Product Category". As you see on the screenshot, order number 15589543 has one Connected Product Category that displays "Connectable".
Since this order number does not only have null field for the Connect Product Category, I would like ALL of the rows (even the blank ones) be displayed for order # 15589543. If an order # has NO rows that have "connectable" displayed in them (orders 10305573, 15573299, 15699578, etc.) I would like these orders to be filtered out.
This is a screenshot of just a small part of the data. Basically, if an order has a "connectable" field in it, I need all of the rows for that order # to be displayed.
I tried to do logic such as IF [Item: Connected Product Category] = "Connectable" THEN [Order: Sales Order #] ELSE NULL END but this only displays the rows that literally contain "connectable" in them, not all of the rows for that order number.
Any assistance would be greatly appreciated. After extensive research I'm not sure if this is even possible. Thanks
It is simple. Create a calculated field desired filter as
{FIXED [Order: Sales Order #] : SUM(
IF [Item: Connected Product Category] = 'Connectable' THEN 1 ELSE 0 END
)} > 0
This calculated field will evalaute as TRUE/FALSE and setting filter on this field for TRUE will filter records as desired.
Try this. Good luck

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.

Calculated Fields and increments

I am building a system using Starting Point and need help with calculated fields.
Basically when an estimate is created it takes the same ID as the project its linked to with a "-1" 1 being incremental value. So if the increment -1 exists the next estimate for that project would be -2 and so on.
So for example
Project Id: 120000
First Estimate: 120000-1
Second Estimate: 120000-2
I have found out how to add a hyphen and number after the project ID (the stored as estimate ID) like so id_project & "-" & 1 but I have no idea using filemaker how to use calculated fields to look and see if 120000-2 is a thing and if it is make it 120000-3
Any help greatly appreciated
I'm assuming you have at least a relationship between Projects and Estimates. Perhaps something like this (without the Estimates_self table occurrence, which I'll get to in a moment):
If you're in the Projects context (on a layout linked to the Projects table), you can get a count from there using something like Count ( Estimates::id ).
If you want to make this happen from the context of Estimates, create a self-join as shown above, using the project foreign key as the match field. Then you can use Count ( Estimates_self::id ).
Finally, an option without any relationship graph changes would be to use ExecuteSQL:
ExecuteSQL (
"SELECT COUNT(*) FROM Estimates WHERE project_id = ?" ;
"" ; "" ;
Estimates::project_id
)
All of these will give you the number of estimates that a given project has. Add one to that and you have your suffix number for the new estimate.
Count the related estimates based on a parent Project. This will give you the Estimate number after dash

Sort Parameter for 7 different fields in CR 10

I am attempting to write a sort field parameter for all of my 7 fields in CR10. I have followed the directions in the help section - Define sort order using parameter fields - and just tried 3 fields for the moment. I can't get either to work properly and I'm not sure if this is at all possible.
Here is what I have.
My report originally was grouped by 1 Payer ID and then 2 Claim Number. I removed those groups and moved my fields into the details section. Here are the fields:
`Claim#
Payer ID
Payer Name
Account#
Name
Billed Amt
Date`
I created a parameter called Sort Field, selected string and made sure my min and max were set to one. Placed the following into the prompting text:
`C = Claim
I = Payer ID
P = Payer Name
A = Account#
N = Name
B = Billed Amt
Date is Default`
I created a formula and called it Sort. I have tried this as stated above with all 7 fields and also only 3 fields - my main focus is all of the fields.
`If {?SortField} = "C"
Then totext({table.ClaimNumber},"########")
ElseIf {?SortField} = "I"
Then totext({table.ID_Payer},"########")
ElseIf {?SortField} = "P"
Then {table.PayerName}
ElseIf {?SortField} = "A"
Then totext({table.Account},"#######")
ElseIf {?SortField} = "N"
Then {table.Last_Name}
ElseIf {?SortField} = "B"
Then totext({table.ClaimGrossCharge},"#########.##")
Else totext({table.SubmittedDate},"")`
I then placed #Sort into the report header and suppressed in the section expert. I also included the following formula in the Record Selection:
`{table.SubmittedDate} >= {?Submitted Date From} and
{table.SubmittedDate} <= {?Submitted Date To} and
{#Sort} = {?SortField}`
Finally, I made sure that the #Sort formula was selected in the record sort expert.
I run the report and get nothing. I comment out {#Sort} = {?SortField} in the Record Selection and I get data. Although, the data is duplicating since it is not grouped as it was originally.
Can this be done? This option would be amazing for our clients and I have a feeling it can work but I believe I am missing something. Is my #Sort formula correct or does it need to be adjusted? I am attempting to make sure all of the fields are to text since I selected string in the parameter.
Any assistance would be greatly appreciated! Thank you for your time.
Its a bit lenghty question but will try to answer to the extent I understand.
I am assuming sort(From formula that you have written) you mean display only those values that client has selected and supress the rest and my answer will support this idea. If this is not you are looking for let me know will try to answer to the extent possible.
You shouldn't be using the {#Sort} = {?SortField} in record selection formula since this will be directly fired in database and as per your design this won't return any data as you parameter values doesn't match with the data in database.So remove this part from record selection.
Do place your sort formula in report header as it doesn't fetch full data in header and its of no use to supress.
As you place all fields in detail section you can use your created Sort formula in detail section in place of original fields which will do the job as per the user selection.
If you are getting the duplicate data then you need to check links to the tables or check the option Select Distinct Data in database tab which will remove duplicate data

How to retrieve data from related past records

I am using Filemaker Pro 12. I want to create a student report that contains results from previous terms. For example, each year there are 4 terms. The report in term 1 contains only the result of term 1. But in term 2, the report contains the results from both term 1 and term 2. This continues until term 4 (end of year) which the report will contain the results from term 1 to term 4.
I created 4 fields ca1_percent, sa1_percent, ca2_percent and sa2_percent in the Results table. My Results table contains all the records of the past results. My relationship graph is shown in the diagram below:
My problem is that I kept obtaining the records (mark_percent) from CA1 only. My fields calculation is shown in the diagram below:
Can anyone help me?
Update:
The result I obtained from above is shown in the picture below. I have populated upto term 3 results.
Just a thought - might an ExecuteSQL() query to fetch the related ids as a value list, then plonking them into a id-1, id-2, id-3 be more flexible?
I solved the problem myself.
Since Filemaker just take the first matched record by default, what I did is to use GetNthRecord(SA1_Results_Match::mark_percent,2) to get the marks for SA1, using 3 to get the marks for CA2 and 4 for SA2.
My TO only need be matched by overall_percent_match which is a calculated field using year & " " & subject & " " & _kf_studentID.