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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
DavidMDxb
Frequent Visitor

Creating table using DAX and split on a field value

hi Everyone

i ve been searching without find the answer, if can get help please

I have a tab le with the below (example)

 

RouteIDA PointB PointSegmentHeader
1GPSAGPSB

__GPS3__GPS4__GPS5__ ( can be many GPS points here)

 

i need to create a table with the below results (rows results)

RouteID = 1 

RouteIDA PointB Point
1GPSAGPS3
1GPS4GPS5
1GPS5GPSB

 

I guess there is a while to go thru the first table, then a split on the ___ separator, but honestly, i m a bit lost

someone to help ?

thanks!!!

david

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

 

I don't think you will want to do that in DAX.  Here is a Power Query version.

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText("i45WMlTSUXIPCHaEUE5AKj4eyDAGkyZg0jQ+Xik2FgA=", BinaryEncoding.Base64),
        Compression.Deflate
      )
    ),
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [RouteID = _t, #"A Point" = _t, #"B Point" = _t, SegmentHeader = _t]
  ),
  #"Added Custom" = Table.AddColumn(
    Source,
    "Custom",
    each List.Zip(
      {
        {[A Point]} & List.RemoveItems(Text.Split([SegmentHeader], "__"), {""}),
        List.RemoveItems(Text.Split([SegmentHeader], "__"), {""}) & {[B Point]}
      }
    )
  ),
  #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
  #"Extracted Values" = Table.TransformColumns(
    #"Expanded Custom",
    {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text}
  ),
  #"Removed Other Columns" = Table.SelectColumns(#"Extracted Values", {"RouteID", "Custom"}),
  #"Split Column by Delimiter" = Table.SplitColumn(
    #"Removed Other Columns",
    "Custom",
    Splitter.SplitTextByEachDelimiter({","}, QuoteStyle.Csv, false),
    {"A Point", "B Point"}
  ),
  #"Changed Type" = Table.TransformColumnTypes(
    #"Split Column by Delimiter",
    {{"RouteID", Int64.Type}, {"A Point", type text}, {"B Point", type text}}
  )
in
  #"Changed Type"

 

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Your data does not paste properly in an MS Excel file.  Put both those tables in an MS Excel file and share the download link of that file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lbendlin
Super User
Super User

 

I don't think you will want to do that in DAX.  Here is a Power Query version.

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText("i45WMlTSUXIPCHaEUE5AKj4eyDAGkyZg0jQ+Xik2FgA=", BinaryEncoding.Base64),
        Compression.Deflate
      )
    ),
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [RouteID = _t, #"A Point" = _t, #"B Point" = _t, SegmentHeader = _t]
  ),
  #"Added Custom" = Table.AddColumn(
    Source,
    "Custom",
    each List.Zip(
      {
        {[A Point]} & List.RemoveItems(Text.Split([SegmentHeader], "__"), {""}),
        List.RemoveItems(Text.Split([SegmentHeader], "__"), {""}) & {[B Point]}
      }
    )
  ),
  #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
  #"Extracted Values" = Table.TransformColumns(
    #"Expanded Custom",
    {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text}
  ),
  #"Removed Other Columns" = Table.SelectColumns(#"Extracted Values", {"RouteID", "Custom"}),
  #"Split Column by Delimiter" = Table.SplitColumn(
    #"Removed Other Columns",
    "Custom",
    Splitter.SplitTextByEachDelimiter({","}, QuoteStyle.Csv, false),
    {"A Point", "B Point"}
  ),
  #"Changed Type" = Table.TransformColumnTypes(
    #"Split Column by Delimiter",
    {{"RouteID", Int64.Type}, {"A Point", type text}, {"B Point", type text}}
  )
in
  #"Changed Type"

 

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".

big thanks, it works

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors