mercredi 1 juillet 2015

Create a dynamic 'if' statement in Excel without VBA

I have a rather large excel data set that I'm trying to summarise using up to 3 dimensions: region, sector, industry. Any combination of these dimensions can be set or left blank and I need to create a formula that accommodates this WITHOUT using VBA.

Within the data I've set up named ranges to refer to these dimensions.

I'm using an array formula but I'd like to dynamically create a string which is then used as the boolean argument in the array formula.

For instance if:

A1 = "Hong Kong" (region)
B1 = <blank> (sector)
C1 = <blank> (industry)

I create a dynamic string in D1 such that

D1 = (region="Hong Kong")

I then want to use the string in D1 to create an array formula

E1 = {counta(if(D1,employees))}

However, if the user includes a sector such that:

 A1 = "Hong Kong" (region)
 B1 = "finance" (sector)
 C1 = <blank> (industry)

Then I want the string in D1 to update

D1 = (region="Hong Kong")*(sector="finance")

Which then automatically updates the value in E1 which still has the same formula.

E1 = {counta(if(D1,employees))}

Is this possible? Alternatively is there any other way of achieving the same outcome, keeping in mind that I need to be able to copy D1 and E1 down into different rows so that different combinations of the dimensions can be viewed simultaneously.

Thanks.

Aucun commentaire:

Enregistrer un commentaire