I transferred the file from Excel into my Tableau sheet and created two new variables. One is a parameter based on the Sales variable. I set the value at 10,000. Then I created a calculated variable called "Sales Spotlight" that states:
IF(SUM([Sales])) >= [Sales Parameter] THEN "Good" ELSE "Bad" END
This is what the screen looks like:
The result is correct except the values in the table are string values instead of number values. I can't figure out how to change the data in the table to numbers.
To confirm, you want to display Sales as a number in your chart?
In theory, you should be able to do this by changing Mark type from "Automatic" to "Number" (or "Text"?).
Failing that, try dragging Sales from the far-left side on to your viz under Rows, and again explicitly set the Mark type.
Proviso: it's been a while since I've used Tableau and I don't have it available so cannot verify the answer above but it should work.
Related
I'm working on a Tableau table where I'd like to:
Isolate specific string records in a dimension; then
Count the instances that a specific string appears in that dimension (so all the records). A record may have multiple but different texts within.
Let's say my Dimension is called "Person Type" and I have 5 records with these respective values:
Employee, Visitor, Employee; Visitor, Applicant, Visitor; Applicant
I understand that I could first create a filter on the dimension to only show the singular record types: Employee, Visitor, Applicant, but where I'm having trouble is creating a calculation that looks at all the records and counts the instances that the word "Employee" is present in and so forth. In excel, a COUNTIF formula with a text wildcard handles this.
Here's an excel screenshot of what I'm trying to accomplish.
Screenshot
Edit: Tried a calculation that was pretty close to the solution. For some reason it's not counting Applicant, when there's clearly two instances of it. anyone have any idea's on how to improve the calculation?
IF CONTAINS([Person Types],'Employee') THEN "Employee"
ELSEIF CONTAINS([Person Types],'Visitor') THEN "Visitor"
ELSEIF CONTAINS([Person Types],'Applicant') THEN "Applicant"
END
result
issue
You can use the Contains function in your LOD which operates like a wild card *X* in Excel.
So something like:
{ FIXED [NEWFIELD]: SUM(INT(CONTAINS([PERSON],"Employee"))) }
The code
IF CONTAINS([Person Types],'Employee') THEN "Employee"
ELSEIF CONTAINS([Person Types],'Visitor') THEN "Visitor"
ELSEIF CONTAINS([Person Types],'Applicant') THEN "Applicant"
END
will not correctly count "Applicant" if there is an "Employee" or a "Visitor" since they will take precedence (each if is tested in sequence). So for example "Visitor; Applicant" will return "Visitor"
Also CONTAINS is case-sensitive so you might want to convert to all upper case to ensure that any subtle case variances are matched.
IF CONTAINS(UPPER([Person Types]),"APPLICANT") THEN "Applicant"
I recreated a sample like you have shown in your screenshot for a demonstration (it is always advised to copy and paste some rows of data directly in the code)
Steps (Tableau Desktop) It is though easier in Prep-
In the data source pane after connecting your data, click a down arrow on the person type field and click split
Two new field will be automatically created (given that maximum person types in one record is 2) or more rows will be created. (It is highly advised to have Tableau Prep) In tableau prep you can directly PIVOT these fields. See method here. But pivoting on calculated fields is not there in Tableau Desktop
Union the data with itself n (=2 here in this case) number of times. See GIF for help
create a calculated field say person types (I added a s intentionally to differentiate) with the following calculation
// A single person_type for each row.
CASE [Table Name]
WHEN "Sheet1" THEN [Person Type - Split 1]
WHEN "Sheet11" THEN [Person Type - Split 2]
END
Excluding null values you can create your desired views
Needless to say that you have to change values of [table name] as per your case in the calculated field
I have a huge table with data structured like this:
And I would like to display them in Spotfire Analyst 7.11 as follows:
Basically I need to display the columns that contain "ANTE" below the others in order to make a comparison. Values that have variations for the same ID must be highlighted.
I also have the fields "START_DATE_ANTE" and "END_DATE_ANTE" which have been omitted in the example image.
Amusingly, if you were limited to just what the title asks, this would be a very simple answer.
If you wanted this in a table where the rows are displayed as usual, and the cells are highlighted, you can do this by going to properties, adding a newGrouping where you select VAL_1 and VAL_1_ANTE and add a Rule, Rule type "Boolean expression", where the value is:
[VAL_1] - [VAL_1_ANTE] <> 0
This will highlight the affected cells, which you can place next to each other. You can even throw in a calculated column showing the difference between the two columns, and slap it on right next to it. This gives you the further option to filter down to only showing rows with discrepancies, or sorting by these values.
However, if you actually need it to display the POSTs on different lines from the ANTEs, as formatted above, things get a little tricky.
My personal preference would be to pivot (split/union/etc) the data before pulling it in to Spotfire, with an indicator flag on "is this different", yes/no. However, I know a lot of Spotfire users either aren't using a database or don't have leeway to perform the SQL themselves.
In fact, if you try to do it in Spotfire using custom expressions alone, it becomes so tricky, I'm not sure how to answer it right off. I'm inclined to think you should be able to do it in a cross table, using Subsets, but I haven't figured out a way to identify which subset you're in while inside the custom expressions.
Other options include generating a table using IronPython, if you're up to that.
I have an excel file that has one column which contains numbers that represent file sizes, each of those numbers is a floating point number with a max decimal places of two (Ex: 23.04). the total cells count is (277 cells).i want to automatically group cells that add up to (1000) or as close as possible to that number (1000). the sum of all the cells is (5739.49) so, there should be (4) groups of cells, each adds up to (1000) and the last one (5th group) doesn't matter how much it adds up to. now :
I know that this can be solved using "THE SOLVER" in excel for each group But i'm
not sure what constraints i should use and which solving method (i.e, the simplex, GRG nonlinear or the evolutionary) methods because i'm not familiar with it
thank You in advance
As I mentioned in the comment, the standard solver in Excel has a maximum limit for decision variables of 200.
This example is limited to 200 variables - if you have the premium solver, you can expand the solution. This was done using Excel 2016.
Worksheet setup
Column A contains the size data.
Column B contains the "Group" that each member in Column A will belong to. It is initially populated using the formula =RANDBETWEEN(1,5). It was then overridden using Copy / Paste Special - Values.
Column D contains the aggregated groups, labelled 1 through 5.
Column E contains the aggregated size within each group. It is calculated with =SUMIF($B$2:$B$201,"="&D2,$A$2:$A$201)
Column F contains the target value for each group (1000 for groups 1 through 4, ignored for group 5).
Column G contains the squared error from the target value for each group. It is calculated with =(E2-F2)^2
Cell G7 will be the "Set Objective" cell and is the sum of error squared. It is calculated with =SUM(G2:G5)
Below is a screen shot of the setup worksheet, before using solver.
Solver Setup
Solver is setup with the following criteria ...
"Set Objective:" is $G$7
"To:" is "Min"
"By Changing Variable Cells:" is $B$2:$B$201
"Subject to the Constraints:" includes: $B$2:$B$201 <= 5, $B$2:$B$201 = integer, and $B$2:$B$201 >= 1
"Select a Solving Method:" is Evolutionary. Note: You could use GRG, but it will be much slower.
In "Options", on the "All Methods" tab, in the "Solving with Integer Constraints" area, make sure Ignore Integer Constraints is not checked.
Below is a screen shot of the Solver Parameters dialog:
Solution
Your optimal region may be "flat" so there are multiple possible solutions.
Below is a screen shot of a solution I generated ...
In my SSAS cube I have a dimension that includes 6 date fields. They are all defined in the same way, with a Key field that is a date type and a Name field that is char(10) in format yyyy-mm-dd.
When I include those fields in an Excel pivot table, they all work fine except one. That one field is displayed correctly, but doesn't behave correctly when filtered. In particular, specifying a between filter always returns zero rows. Same with a greater than filter. Begins with works fine.
Once again, this only happens for one of the six date fields. But all six date fields are configured identically as far as I can tell. What type of mistake could cause this?
EDIT
Using SQLServer Profiler I can see that the MDX generated from Excel are identical for the dates that work and the one that doesn't (except for the field names changing of course). If I restrict the pivot table to a single date and add a between filter then the MDX is:
SELECT NON EMPTY Hierarchize({DrilldownLevel({[Participation Program].[Participation Start Date].[All]},,,INCLUDE_CALC_MEMBERS)})
DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON COLUMNS
FROM (SELECT Filter([Participation Program].[Participation Start Date].[Participation Start Date].AllMembers,
([Participation Program].[Participation Start Date].CurrentMember.member_caption>="1985"
AND [Participation Program].[Participation Start Date].CurrentMember.member_caption<="1990")) ON COLUMNS
FROM [Compass3])
WHERE ([Child].[Child is Handicapped].&[T],[Measures].[Child Count]) CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, FONT_FLAGS
That returns correct results for [Participation Start Date], but if I do the same thing with [Participation Stop Date] it returns 0 results. So it is a problem on the SSAS side rather than Excel side. But I still can see no difference in the way the two dates are configured in the cube, and I am 100% certain that there is data that should match the specified date range.
I would change the Key for those attributes to a numeric representation of the date in YYYYMMDD format. I would achieve this via a SQL View where I would use the CONVERT function.
I would not use the date datatype at all in SSAS, as it's internal representation is obscure/uncertain.
I've come across a similar problem using epplus. If you haven't defined the date explicitly, Excel may not realize that the data is a date. This causes problems with sorts and filtering. (Note that the code below is C#, but the idea behind it with respect to the excel formulas/formats should be the same.)
When you generate the excel cell, explicitly define a date formula in the cell:
ws.Cells[rowCount, columnCount].Formula = "=DATE(" + myDate.ToString("yyyy,M,d") + ")";
Then, set the cell formatting to display the date the way you want:
ws.Cells[rowCounter, columnCount].Style.Numberformat.Format = "d-mmm-yyyy";
In this url, it is shown how you can format a particular column to according to particular currency.
http://publib.boulder.ibm.com/infocenter/caapps/v10r1m0/index.jsp?topic=%2Fcom.ibm.swg.im.cognos.ug_fm.10.1.0.doc%2Fug_fm_id13919format_SAP_query_items.html
Now in a result set, there may be 2 rows and each may be of a different currency and also different number of decimals. According to the method here, it seems that we need to hard code the currency and the number of decimals on the entire column. Is there a way to set it dynamically?
I have two columns in the result set, one is the amount the other one is the currency. Based on currency, i want to format the amount column. From db, the amount column just comes back as a number.
How can I do it?
I can't think how this would be done in Framework Manager. You can do it in Report Studio however.
He are some high level instructions on how to do it in Report Studio:
In Condition Explorer, create a variable which results in a different string for each currency. For example if your currency code field is [Table].[CurrencyCode] and it has things like 'AUD','CAD' etc. in it then your variable expression would just be the field:
[Table].[CurrencyCode]
This will simply output the currency as its result
Still in the variable creation screen, add values the the 'Value' window to for each possible currency code result
Go to the report page, click on the field that contains your actual currency value (i.e. 13.50 and set it's Style Variable property to the variable that you just created
Now go back to condition explorer and select your first currency
Ensure your currency value field is selected and edit the 'Data Format' field to the appropriate format
Repeat 4 & 5 for each currency
Here is another guide to how to do this:
http://www-01.ibm.com/support/docview.wss?uid=swg21339405
This is called 'Conditional Formatting' if you would like to research it further.
Unfortunately this solution needs to be done at the report level and can't be done down at the the FM level. I'm not aware of a way that you can conditionally set the data format in FM like this.