Spotfire, Calculated Columns to show Percentages - percentage

I hope you are well and that you can be of assistance. I have a table and I need calculated columns to show what percentage of 'No' 'Yes' and 'Empty' I have. I have attached a picture below.
Any help with the syntax would be greatly appreciated.
error screenshot posted by Philip Connell:

#Philip Connell - I have created a calculated column 'consent%' with the below expression and change the format of this column to percentage from column properties.
[number] / [Total amount]
Used this calculated column in a cross table. Screenshots below.
Please let me know if this is the solution you are looking for.
Refined solution:
I have created some sample data for the sake of explanation.
Added pivot transformation (count of customer ID) while loading sample data into Spotfire.
Created two calculated columns.
Total amount:
Sum([count of Customer_ID]) over ([Country])
consent%:
[count of Customer_ID] / [Total amount]

The solution is below
Count([CUSTOMER_ID]) as [No. Of Customers], Count([CUSTOMER_ID]) THEN [Value] / Sum([Value]) OVER (All([Axis.Columns])) as [Percentage ]
Thank you all for the support

Related

Stata tables/collect confidence interval in one cell

I work a lot with the new tables collect command in stata 17. Does anybody know how to get the confidence interval in one cell in the table vs. One column for lower bound and one column for the upper bound estimate?
Alternatively a quick fix in word (or excel though my final document is word. Saving the output in excel takes so long)
Is I see it there is no option to put it in one column, so maybe a layout work around?
From the stata documentation of the collect command, the quick start mentions
table (colname) (result), command(_r_b _r_ci: regress y x1 x2 x3). You should be able to use collect with it, but without a minimum reproducible example of your specific case, it is hard to verify if this works as intended in your case. For the general idea of a minimum reproducible example please see here and for specific advice on how to create a minimum reproducible example please see here.
Here is a general example that uses table, collect and putdocx to create a word document to get the confidence interval in one cell:
use https://www.stata-press.com/data/r17/nlsw88.dta
table (colname) (result), command(_r_b _r_ci: regress wage union occupation married age)
collect layout (colname) (result)
putdocx begin
putdocx collect
putdocx save Table, replace

QlikView - How to make a filter in one column and then get the maximum on the other column

I am trying to apply a filter in one column model_number and then the maximum number of the other filed, Week.
This is the formula that I tried.
=if(WildMatch(model_number,'*4*'),Max(Week,1))
Does anyone can help me to formulate this?
You can use set analysis to filter the data.
In your case the expression can be written in this way:
max( {< model_number = {"*4*"} >} Week, 1)
The max function will be calculated only on the records that fulfil the condition applied on model_number field.

Creating a vector for multiple observations in R

I have a similar table as shown in this example (mine has more variables but the problem remains the same). I need observations taken in the same counties to be given the same index, and stored in J
I need to create the vector J as shown on the right hand side of the picture, can anybody help me with this? The table can be found here. Thanks.
It appears that you would just use your county column?
j = randomdata$county which you can subset as j[919] and get 85.

Percentage Calculation in Spotfire

This is the data that i've in Spotfire like this and trying to arrive at a percent calculation with the logic.
The formatting messed up the first time i posted the question.
Percentage for Instagram: (Count of Instagram) / (Count of all Social network)
Can you please help me with the calculation?
I'd do it with a cross table:
set "Question# 1" as row header
enter this expression as value: Count() / Count() over (All([Axis.Rows]))

How to change the value in a group of cells?

I'm wondering if it is possible to change the contents of multiple cells in a table using R?
Consider this example: Example
I need to change the values 'Femini.' to 'Feminine'. The problem is that i have a great number of cells to change... Is there some command that help me doing this?
Thanks for the help,
Luís
Say your dataframe is called df
df$Genre[df$Genre == 'Femini'] <- 'Feminine'

Resources