Forum Discussion
Arun Chandramouli
Jan 05, 2022Brass Contributor
Help with Formula/ Power query to get the number of matching row counts of codes
Hi All, Hope you are doing well!... I have the input data at a ctextid and a vbillid level...I also have the list of codes input by a human (agentcode) and the number of codes input by an automat...
SergeiBaklan
Jan 07, 2022Diamond Contributor
Thank you for the sample.
Perhaps like this
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
agentList = Table.AddColumn(
Source,
"agentlist",
each List.Transform(
Text.Split([agentcode], "," ),
each Text.Trim(_) )),
predictList = Table.AddColumn(
agentList,
"predictlist",
each List.Transform(
Text.Split([predictcode], "," ),
each Text.Trim(_) )),
#"Expanded agentlist" = Table.ExpandListColumn(
predictList,
"agentlist"),
matching = Table.AddColumn(#"Expanded agentlist",
"Total Matching",
each fnCount( [predictlist], [agentlist] )),
#"Removed Other Columns" = Table.SelectColumns(
matching,
{"agentlist", "Total Matching"}),
#"Grouped Rows" = Table.Group(
#"Removed Other Columns",
{"agentlist"},
{
{"total number", each Table.RowCount(_), Int64.Type},
{"total matching", each List.Max([Total Matching]), type number}}),
percent = Table.AddColumn(
#"Grouped Rows",
"% matching",
each [total matching] / [total number], Percentage.Type)
in
percent
with function
(lst as list, v as any) =>
let
Source = List.Count( List.Select( lst, each _ = v) )
in
Source
Arun Chandramouli
Jan 07, 2022Brass Contributor
Hi SergeiBaklan....Really appreciate you getting back...Please find attached the example in which it is failing...I have highlighted the same in the output tab...
- alannavarroJan 07, 2022Iron ContributorIn the file of Sergei Baklan, I think that you just need to change the step "Grouped Rows" in the "Table" query. It should work.
Right now
{"total matching", each List.Max([Total Matching]), type number}})
Change it for
{"total matching", each List.Sum([Total Matching]), type number}})- SergeiBaklanJan 07, 2022Diamond Contributor
alannavarro , Arun Chandramouli
Perhaps, thank you. But when U071 gives 57%, however 14% is marked as correct result.