Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
blazko
Helper III
Helper III

common character position

Hi! I need help with finding the the common character (or characters) in column (by a category from another colummn).
ex '123G456', '789G321' have common G on third position. So im looking a column to make that would look like that maybe:   '...G...'. So the output would look like:

'J....G..'
...KJH...'

etc

DAX or M. Thx for any help! 

1 ACCEPTED SOLUTION

@blazko 

 

Try this.

Please see attached file's Query Editor as well for steps

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dcpBCoNADIXhu8xaQhJnxmSttIuK4FLEhbjoBXoAT+PBPEknhYKKs3vv5xtHt8wfcoUL9VPRx8fw+p993QDcVJyJxKYLt4RTRSZEmkXTBrCdyBGo/ABxDoRo8a1yB8oUhepeGLE1YBsA2iNQi8RlFpBFlSoLKosx+AuYvg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Column1"}, {{"ALL", each _[Column2], type list}}),
    #"Added Custom2" = Table.AddColumn(#"Grouped Rows", "Custom.2", each Text.Combine(Table.AddColumn(Table.FromColumns(List.Transform([ALL],each Text.ToList(_))),"Result",each 
let mylist=List.Distinct(Record.ToList(_)),
mycount=List.Count(mylist)
in
if mycount=1 then Text.Combine(mylist) else "."
)[Result])),
    #"Expanded ALL" = Table.ExpandListColumn(#"Added Custom2", "ALL")
in
    #"Expanded ALL"

View solution in original post

4 REPLIES 4
Zubair_Muhammad
Community Champion
Community Champion

@blazko 

 

Could you copy paste some sample data with expected results?

ok

 

cat15CG9046FYK5CG90…..
cat15CG9086DN55CG90…..
cat2021001a89..1001…
cat2981001a12..1001…
cat2561001g98..1001…
cat381CQ8200L.1CQ8...L
cat391CQ8123L.1CQ8...L
cat311CQ8987L.1CQ8...L
cat371CQ8654L.1CQ8...L

@blazko 

 

Try this.

Please see attached file's Query Editor as well for steps

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dcpBCoNADIXhu8xaQhJnxmSttIuK4FLEhbjoBXoAT+PBPEknhYKKs3vv5xtHt8wfcoUL9VPRx8fw+p993QDcVJyJxKYLt4RTRSZEmkXTBrCdyBGo/ABxDoRo8a1yB8oUhepeGLE1YBsA2iNQi8RlFpBFlSoLKosx+AuYvg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Column1"}, {{"ALL", each _[Column2], type list}}),
    #"Added Custom2" = Table.AddColumn(#"Grouped Rows", "Custom.2", each Text.Combine(Table.AddColumn(Table.FromColumns(List.Transform([ALL],each Text.ToList(_))),"Result",each 
let mylist=List.Distinct(Record.ToList(_)),
mycount=List.Count(mylist)
in
if mycount=1 then Text.Combine(mylist) else "."
)[Result])),
    #"Expanded ALL" = Table.ExpandListColumn(#"Added Custom2", "ALL")
in
    #"Expanded ALL"

Just wow! I can't thank you enough! Works as a charm!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.