Make multiple custom columns in one step.

Nole321

New Member
Joined
Jun 2, 2021
Messages
11
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
In power query, I need to make multiple columns to build on an equation and I don't want 40 custom columns in my steps. How can I make my below equation run through one step (probably two for expanding columns) for 10+ columns? The columns called for a and b change FYI.

Power Query:
= Table.AddColumn(#"Replace From List", "Dup1 ScoreName1", each let
    a = List.Distinct(Text.Split([#"Customer - Copy1"], " ")),
    b = List.Distinct(Text.Split([#"NameLine1 - Copy1"], " "))
in try
    List.Count(List.Intersect({a, b})) / List.Count(a) otherwise null)
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
I figured it out. Here is it for anyone needing help.

Power Query:
= Table.AddColumn(
    #"Replace From List",
    "Many",
    each 
        let
            a = List.Distinct(Text.Split([#"Customer - Copy1"], " ")),
            b = List.Distinct(Text.Split([#"NameLine1 - Copy1"], " ")),
            c = List.Distinct(Text.Split([#"NameLine2 - Copy1"], " ")),
            d = List.Distinct(Text.Split([#"NameLine3 - Copy1"], " ")),
            e = List.Distinct(Text.Split([#"NameLine4 - Copy1"], " ")),
            f = List.Distinct(Text.Split([#"ShortName - Copy1"], " ")),
            ScoreName1 = try List.Count(List.Intersect({a, b})) / List.Count(a) otherwise null,
            ScoreName1desc = try List.Count(List.Intersect({b, a})) / List.Count(b) otherwise null,
            ScoreName2 = try List.Count(List.Intersect({a, c})) / List.Count(a) otherwise null,
            ScoreName2desc = try List.Count(List.Intersect({c, a})) / List.Count(c) otherwise null,
            ScoreName3 = try List.Count(List.Intersect({a, d})) / List.Count(a) otherwise null,
            ScoreName3desc = try List.Count(List.Intersect({d, a})) / List.Count(d) otherwise null,
            ScoreName4 = try List.Count(List.Intersect({a, e})) / List.Count(a) otherwise null,
            ScoreName4desc = try List.Count(List.Intersect({e, a})) / List.Count(e) otherwise null,
            ScoreNameShort = try List.Count(List.Intersect({a, f})) / List.Count(a) otherwise null,
            ScoreNameShortdesc = try List.Count(List.Intersect({f, a})) / List.Count(f) otherwise null
        in
            [ScoreName1 = ScoreName1, ScoreName1 desc = ScoreName1desc,
            ScoreName2 = ScoreName2, ScoreName2 desc = ScoreName2desc,
            ScoreName3 = ScoreName3, ScoreName3 desc = ScoreName3desc,
            ScoreName4 = ScoreName4, ScoreName4 desc = ScoreName4desc,
            ScoreNameShort = ScoreNameShort, ScoreNameShort desc = ScoreNameShortdesc]
)

It produces a record, and you can then just expand the record.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top