Output a String that has the categorical value of the final sum seperated out? - tableau-api

Say I have a field [Client] which is either Yes/No
Then I Sum on [NumberOfAccounts]
But on my map I want a string that says "Clients: 23 Prospects: 11 Total: 33"
How do I do that with a calculated field??

Assuming you have one record, i.e. row of data per account, and an account is either a client or prospect depending on the value of the [Client] field. Further recommend you change Client to a Boolean valued field, taking on either True or False, instead of using a string, and finally assuming you rename the field [Client?]
Give all that, you define a calculated field called [Clients] as
INT([Client?])
And then you can put SUM([Clients]) on the Text/Label shelf to get the number of clients.
Likewise, you can define a calculated field called [Prospects] as
INT(NOT [Client?])
And also put SUM([Prospects]) on the Text/Label shelf.
This works because the type conversion function INT() converts True to 1 and False to 0. Then the SUM() function effectively counts the number of records that satisfy the Boolean condition.
Finally, also add SUM([Number of Records]) to Text/Label.
Once the measures are included in text or label, you can edit the label text by clicking on the Text/Label button on the marks card to add the surrounding strings.
BTW, The button is called either Text or Label depending on your choice of mark type.

Related

Is there a way of creating a Serial Number based on other inputs on a MS access form?

I have some samples I need to take.
In order to create a good identifier/serial number for the samples, I want it to be a product of its characteristics.
For example, if the sample was taken from India and the temperature was 40 degrees then I would click dropdowns in the form to create those two entries and then a serial number would be spat out in the form "Ind40".
Assuming that your form is bound to a table, you can create a calculated column in the table that concatenates the values from other columns into a single value.
For instance, create a new column and give it a name (for example, SerialNbr). Then for Data Type select "Calculated". An expression builder window will appear:
Enter the columns you'd like to concatenate and separate them with &. Here is an example of how the expression could look:
Left([Country],3) & [Temperature]
This expression takes the first 3 chars from the Country column and combines it with the value from Temperature column to create the value in column SerialNbr. The calculated column will automatically update when values are entered into the other fields. I'd also suggest adding another value to the calculated expression to help avoid duplicates, such as date/time of submission.

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.

Add filter/parameter in calculated field tableau

I'm trying to create calculated field in tableau, my below query is showing valid, however I want to give filter or parameter to it. For ex: I have a field called Account number and I want my below query to show sum of all the quarters revenue on account number level.
Sum(If ([Qtr]='2019-Q1' OR [Qtr]='2019-Q2' OR [Qtr]='2019-Q3' OR [Qtr]='2019-Q4')
THEN FLOAT([Revenue]) END)
Your logic will work.
For parameter: Create a parameter with String data type, add all field names to it. Then create a calculated field based on the parameter list. Add that calculated field to row shelf then change Parameter, the above formula will be recalculated.
For Filter: You can add filter directly.
1st option:
Add Account number as row in your worksheet
Create a Parameter String with values: 2019-Q1, 2019-Q2, 2019-Q3, 2019-Q4
Update your calculated field to:
If [Qtr]='Parameter Value' THEN FLOAT([Revenue]) END
Add this field as text and the value of sum will be for only that Qtr period
2nd option:
Add Account number as row in your worksheet
Create a Parameter String with values: 2019-Q1, 2019-Q2, 2019-Q3, 2019-Q4
Update your calculated field to:
[Qtr]='Parameter Value'
Add this field to the filters and the whole worksheet will filter on that Qtr period
You can also add another parameter for the year to be more flexible on the years

Perform analysis on last three values of a FileMaker dataset

My end goal is to have a box change color when the last 3 records input into a field (based on the time of input) in FileMaker achieve a certain criteria (ex. variance < 2). I would like to know how to make this happen, or how a calculation/script can be written to only look at the last 3 records.
There are several ways you could approach this. A simple one would be to use a script to:
Show all records in the given table;
Unsort them (assuming they were entered in chronological order; otherwise sort them by creation timestamp);
Omit all records except the last three;
Get the value of a summary field defined as Standard Deviation of your value field;
Set a global variable/field to the square of the returned value.
Then use the global variable/field to conditionally format your "box".
If you don't want to use a script, you will have to define a relationship in order to get the last three values in the table, regardless of the current found set and/or sort order. Or you may use the ExecuteSQL() function for this.

Field Value Hidden Unless Data Record's Cell Selected

When I view a particular FileMaker Pro layout, the calculated field Invoice Check Grouping shows up as blank when viewed in either list or grid mode. However, while in grid mode, if I click on a particular Invoice Check Grouping cell, the expected value appears.
In the above image, note how only the currently selected Invoice Check Grouping cell's value shows. I would expect all cells in that column to correctly show their values all the time.
How would I get this column's value appearing all the time? (Note: Invoice Check Grouping is a computed/calculated field.)
Thank you,
Ben
There's something wrong with either the formula itself or, perhaps, the field's formatting. E.g. it could be that the calculation type is set to Number, and the field's Number formatting is set not to show the value when zero. If this is not the case, I'd check the field's conditional formatting rules and then the formula itself.