There is a table of 12 columns. I would like to add an extra column, where each entry stores the average value of the corresponding row across those 12 columns. I use the feature "Calculated new column" to fulfill this task. After getting the result, I noticed that the average value was returned as zero when one of the 12 columns has zero value on that specific row. For other rows, the calculation is just OK if none of the entries in those 12 columns is zero. I attached the screenshot of resulting table and the calculation procedure in the data table properties for your reference. Would you like to let me know the possible reason?
average value was returned as zero when one of the 12 columns has zero
Actually you don't have zero values, but null values, which is different! Use SN() function to manage null values (need to use for all the columns)!
Related
I have a question. I'm collecting social media statistics (likes, shares, comments, etc.), and one thing that I'm trying to do is get Excel to tell me the date that the largest number of hits occurred, what post it was on, and what type it was.
I'm part of the way there--I can get Excel to tell me what the highest number is (MAX, easy!), but I can't get it to lock in the date properly.
The way I've got it set up is: there's a single row for each day of the month, with the dates in column A, and additional columns for the types of engagements I'm tracking. At the very bottom of the table is a row with all the MAX values from each column (so in other words, column B will have Likes, column C is shares, and so on, so I can enter a new value for each analytic every day.
Essentially, what I'm trying to do is get Excel to do this, in order:
Look along the row with all the MAX values to find the highest value;
Look up above that (same column) into the data rows until it finds that MAX value;
Take note of the row where it found that MAX value, and return the value of the date from Column A
Make sense? I've got a formula set up with INDEX and MATCH, but while it is giving me the correct numbers for the top value and what type of analytic it is, I can't seem to get the correct date (what it looks like it's doing is counting the columns from left until it finds the value for #2, then counting that number of rows down).
Can anyone help?
You can do this by nesting MAX, MATCH and INDEX
Mockup of your data
The Formula
=INDEX(Table1[Date], MATCH(MAX(Table1[#Totals]), INDEX(Table1, , MATCH(MAX(Table1[#Totals]), Table1[#Totals], 0) ), 0 ) )
Explanation of the Formula
Of course, you don't have to use a Table. A formula for the same data, without Structured References
=INDEX(Sheet1!$K$2:$K$10, MATCH(MAX(Sheet1!$K$11:$P$11), INDEX(Sheet1!$K$2:$P$10, , MATCH(MAX(Sheet1!$K$11:$P$11), Sheet1!$K$11:$P$11, 0) ), 0 ) )
I am trying to create a custom column in power query that counts null values from column 7 - column 41. The function I have used is List.NonNullCount(List.Range(Record.FieldValues(),7,41))). There are many many rows of data so I would like it to calculate each row within the custom column.
For some reason even though each column between 7-41 has null values across the row the output is 2. I would expect the output to be 0. Futhermore I am getting an output of 35 when all columns from 7-41 have a value not equal to null across the row. I would expect 34 in this case. I did replace all blank values with null using the transform function in power query.
I'm not sure if my function List.NonNullCount(List.Range(Record.FieldValues(),7,41))) is correct or if there is a better way to do it. any help appreciated!!!!
In my version, you need to have an argument for Record.FieldValues. What you write: Record.FieldValues() would produce an error.
Also, the third argument of List.Range is the number of columns to return; it is not the number of the last column.
And the first column is column 0, not column 1
So something like:
List.NonNullCount(List.Range(Record.FieldValues(_),6,35))
should return the nonNull count for columns 7-41
I have column ('CSAT') in a sheet that has numbers 1 and 0 in each cell. '1' represents 'Satisfied' and '0' represents 'Disatisfied'. I want to make a pivot from this sheet and have a new calculated field in it ('CSAT %') that will give me the score by dividing (Total 'Satisfied') count by (Total 'Dissatisfied + Total 'Satisfied') * 100.
I tried with COUNTIF but i dont think we can use this formula in pivot
Calculated Fields and Items in PivotTables are tricky. The main tripping point is understanding that Calculated Fields and Items operate on the totals, not on the individual values in the underlying data.
For example, if you created a new Field that was equal to Field1 * Field2 and data is being summarized by SUM, Excel doesn't multiply all of the respective values in each field and then sum the results. It first sums the fields for each category and then multiplies those results. What it's really doing is SUM(Field1) * SUM(Field2) for each category.
You can use some worksheet functions in the calculated fields, but you have to remember you're still operating on the totals. So if you created a new Field that was equal to Count(Field1) * Count(Field2), you're (almost) always just going to get an answer of 1. This is because the calculation is actually doing Count(SUM(Field1)) * Count(SUM(Field2)) for each category. The sum of each field is a single number, so the calculation is just doing 1*1 for each category.
So for this reason, you can't use aggregating functions like SUMIF or COUNTIF which need to look at each individual elements. Since you need to look at individual elements, you actually can't use a Calculated Field for your solution at all.
What you can do is use a Calculated Item!
The main catch here is you can't use any field in more than 1 location when calculated items are involved. Excel just throws an error message saying you're not allowed.
So if you have a category column as well as the CSAT column, you need to create another dummy column full of 1's to operate on.
You can then set up pivot table as follows:
Category field to Rows.
Dummy field to Data area, summarized by Sum
CSAT field to Columns
Click on the CSAT column headers in the pivot table and choose: PivotTable Tools > Fields, Items, & Sets > Calculated Item
Set Name for your new Item to CSAT%
Enter the formula: ='1'/('0'+'1')
On the CSAT field, hide items 1 and 0, so only the CSAT% field is visible
Result:
A couple of notes:
When entering fields and items in calculated fields and items, do so by placing the cursor where you want in the Formula then double clicking on the field/item name from the lists below. This will add brackets and quotes as required in the correct format.
Note that the formula doesn't need SUM around the item names, because calculated fields/items always work on the total of values. They are totalled according to how the data is summarized in the pivot table.
The dummy column was added with all values of 1 so that summing these values gives you the count, from which the percentage can be calculated using the formula specified.
Answer without using calculated fields:
Assuming you have categories in the row fields, you can put CSAT as a column field as well as a data field then choose to summarize values by Count and show values as a percentage of row totals:
After putting CSAT in column and data fields, right click on the data and select Summarize Values By > More Options...
First choose to Summarize Values By Count:
Then click Show Values As tab and select % of Row Total:
You'll then have percentage of 1's under the CSAT=1 column:
I'm struggling to find much useful documentation on Excel 2013 pivot table calculated fields.
My pivot table is fairly simple. I have a 'Company' dimensions as rows (e.g. 'A', 'B' etc) and calendar weeks as columns ('1' --> '52'). The value in the grid shows a date based status value. For example, for Company 'A' there are date based state source rows that are shown under 'week 6', 'week 14' and so on.
What I'm trying to do is inject a value into this pivot table to replace blank/null values. For instance, for Company 'A' there are no values for weeks 7 thru 13. In this case I want to inject a calculated field that looks for the last known value for Company 'A' and then uses that last know value. In this case the calculation for week 7 would detect that the value is null and find the last non-null value (week 6) and use that. The equation might be something like:
derived state = if(State=0, if(previous non null value > 0, previous non null value,0),0)
However, I can't find any docs that explain how to set up an equation that uses multiple dimension references and uses some form of lag or last known value finder function.
Any suggestions?
Thanks in advance!
One workaround is to fill in your null values. Then use the new data as the source for your pivot table. Below is a method of "copying" your data without modifying the original.
If this is your source data starting in cell A1:
1 2 3 4 5
1/1/2014 1/8/2014 1/15/2014 1/22/2014 1/29/2014
1/2/2014 1/9/2014 1/16/2014 1/23/2014 1/30/2014
1/3/2014 1/10/2014 1/17/2014
1/4/2014 1/11/2014 1/18/2014
this formula in cell F2 and pasted across will fill in your blank cells in for week 4 and 5.
=IF(A2<>"",A2,MAX(OFFSET(A2,0,-1*(A$1-1)):A2))
Step by step through the formula
check that A2 is not blank
if it isn't blank, copy the value in A2
if it is blank, choose the max (most recent) date from that row
the max should suffice for getting the last non-null value if the week columns are chronologically ordered
In Microsoft Excel, how can I compute a range (portion of a column), based on the values in another column of the same table, returning the result in an Array form for further processing by other functions?
In SQL, what I mean is "SELECT field1 FROM table WHERE field2=value".
The selected results will be fed (twice) to FREQUENCY(), to compute the number of distinct entries in "field1". That is: given an existing table like this:
Box Date
1 07/01/12
13 07/01/12
13 07/01/12
27 07/18/12
13 07/18/12
55 07/18/12
I want to produce a resulting table like this:
Boxes Date
2 07/01/12
3 07/18/12
Note that "13" is only counted once in the first date ("distinct"), but it's still counted again in the second date.
I already have an expression that does the right thing for the whole of the table,
=SUM(N(FREQUENCY(Box,Box)>0))
where "Box" is a named range of the first table, consisting of the whole Box column. (Using the same range/array/list as the data and the bins for FREQUENCY is a stupefyingly subtle trick actually contained in the Excel help but -- alas! -- by no means adequately explained.)
But I want (several) subsets, one for each date. I want to expand my "SUM(N(FREQUENCY…" expression to act only on the rows of the first table whose Date column matches the Date column of the row being computed. That is, again resorting to SQL,
SELECT count(DISTINCT t1.Box), t2.Date
FROM `t1` JOIN `t2` ON (Date)
GROUP BY Date
I can even build a pivot table of the interesting values (which gets me counts in its cells), then use a parallel, date-indexed column of
=COUNTIF(…)
to reduce each row of counts down to a single count of uniques for that date. But this requires me to update the pivot table to notice new data in the base table, and then to drag-expand the column of answers to include the new date (or suffer ugly value error markers). So something more automatic, less fussily manual, would be sweet.
I guess not available when you asked, but Excel 2013 has Distinct Count as an option in a PivotTable: