Jan 20 2020 08:40 AM
Jan 20 2020 10:36 AM - edited Jan 20 2020 10:40 AM
I think what you need, rather than a Function, is a different way of thinking of your data. See the attached. I've reconfigured your data into a different kind of table, and then used Excel's Pivot Table capability to summarize the data. I believe the summary gives you exactly the kind of accounting you need.
You'll notice that I used VLOOKUP to populate the final column in the new table. It might be just as useful to use a drop-down (under Data Validation) to give yourself a choice of consistent labels for that column, rather than a number and a VLOOKUP.
You may or may not want to put the NAME of your partners in, and I just put junk in there, but it serves as a field to produce the count. But the Pivot Table is an excellent and easy (once you master it) way to produce the kind of summary data you're seeking.
Jan 20 2020 11:22 AM
Jan 20 2020 11:25 AM
Start this formula in the Counts sheet, cell B2:
=SUM(IF(OFFSET(Data!$A$1,MATCH($A2,Data[[Project ]],0),1,1,7)=SUBSTITUTE(SUBSTITUTE(B$1,"Number of ","")," Partners",""),1,0))
Ctrl+shift+enter
Please read @mathetes 's suggestion. It's great advice unless you prefer to write complex array formulas.
Jan 20 2020 11:36 AM
SolutionOne more variant
in B2
=IFNA(COUNTIF(INDEX(Data,MATCH($A2,Data[[Project ]:[Project ]],0),),SUBSTITUTE(SUBSTITUTE(B$1,"Number of ","")," Partners","")),0)
and drag it to the right and down
Jan 20 2020 11:54 AM
And one more variant with Power Query
Generated script
let
Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
UnpivotOtherColumns = Table.UnpivotOtherColumns(
Source,
{"Project "},
"Attribute", "Value"
),
FilterBlanks = Table.SelectRows(
UnpivotOtherColumns,
each ([Value] <> "NULL" and [Value] <> "Off")
),
ModifyNames = Table.ReplaceValue(
FilterBlanks,
each [Value],
each "Number of " & [Value] & " Projects",
Replacer.ReplaceValue,{"Value"}
),
RemoveProjectType = Table.RemoveColumns(
ModifyNames,
{"Attribute"}
),
AddIndex = Table.AddIndexColumn(
RemoveProjectType,
"Index", 1, 1
),
PivotProjects = Table.Pivot(
AddIndex,
List.Distinct(AddIndex[Value]),
"Value", "Index", List.Count
)
in
PivotProjects
Jan 20 2020 12:21 PM
Jan 20 2020 01:26 PM
That's a separate question, please start new conversation here https://techcommunity.microsoft.com/t5/excel/bd-p/ExcelGeneral
Jan 20 2020 11:36 AM
SolutionOne more variant
in B2
=IFNA(COUNTIF(INDEX(Data,MATCH($A2,Data[[Project ]:[Project ]],0),),SUBSTITUTE(SUBSTITUTE(B$1,"Number of ","")," Partners","")),0)
and drag it to the right and down