Question

*I'd like to ask that you please do not just say "add a column to your data that..." *I want to know if the pivot table itself can do this.

My data comes from a sql query. The query is inserted into excel via the Data->From Other Sources path. So, going in to edit the query within excel, or open the query itself, editing, and repasting is not ideal, especially when the excel file needs to be distributed.

My raw data is set-up like this. I've put zeros in for blanks, but my flags are either 1 or blank (empty cell)

id   costa costb names ... ... flagA flagB flagC
1    1000  2000  apple ... ... 1     1     1
2    2300  1200  brake ... ... 1     0     1
3    4600  3400  candy ... ... 0     1     1
4    6900  4300  drill ... ... 1     0     0

I want my pivot table to COUNT occurence of items that are flagb and flagc. Usually with only one flag. Your calculated field will be a SUM with formula ='flagb' How can I make the field bebased on two flags, not just one?

Again. I don't want to add a new column to my data as certain flags do not correlate easily, and I have to change the orignial SQL file, as well as the query inserted to excel to stay consistent. Also, I feel the pivot should be able to do this. Any solutions?

Was it helpful?

Solution

use a calculated field, and put the formula as = AND(flagB=1,flagC=1)

you can use multiple tests if you need to check for specific flags, just separate each test with a comma within the AND test (and more complex tests can be made with OR, or combinations of them both

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top