Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi,
I am having difficult time to list D or X if matches the criteria i.e., format consists of three numbers, followed by either X or D, followed by a further three numbers using power query. If matches the format then in Ouput column add X or D otherwise N.
| List | Output |
| 123X325 | X |
| 254D365 | D |
| 689X555 | X |
| 784X444 | X |
| 789D748 | D |
| ABCX899 | N |
| 3456X879 | N |
| 876X8555 | N |
| 2466D854 | N |
Thanks in advance.
Solved! Go to Solution.
@mouzzampk so many ways to do that...
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
repl = List.Buffer(List.Transform({"0".."9"}, (x) => {x, null})),
x = {null, null, null, "X", null, null, null},
d = {null, null, null, "D", null, null, null},
fx = (txt) =>
[lst = List.Buffer(List.ReplaceMatchingItems(Text.ToList(txt), repl)),
check = if lst = x or lst = d then lst{3} else "N"][check],
col = Table.AddColumn(Source, "Output", (x) => fx(x[List]))
in
col
@mouzzampk so many ways to do that...
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
repl = List.Buffer(List.Transform({"0".."9"}, (x) => {x, null})),
x = {null, null, null, "X", null, null, null},
d = {null, null, null, "D", null, null, null},
fx = (txt) =>
[lst = List.Buffer(List.ReplaceMatchingItems(Text.ToList(txt), repl)),
check = if lst = x or lst = d then lst{3} else "N"][check],
col = Table.AddColumn(Source, "Output", (x) => fx(x[List]))
in
col
Thank you!!! 😇
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 7 | |
| 7 | |
| 5 | |
| 3 |