简体   繁体   中英

Data set Transformation for Power BI

Actually i'm working on Power BI to make an analysis of authors publications numbers and trends. I have the data set shown in the image below. A column of authors and and another for their IDs in each cell, i'ev multiple authors at once, the same for their IDs so my question Is there a way to match each author with it's ID so i can proceed my analysis.

Thank you so much

在此处输入图像描述

Since you chose to provide your data as a screenshot, which cannot be copy/pasted into a table, I had to make up my own.

  • split each column into a list
  • combine the two lists into a table

Source
在此处输入图像描述

M Code (Transform=>Home=>Advanced Editor)

let
    Source = Table.FromRecords(
        {[Authors="Author A, Author B", #"Author(s) ID"="12345;67890;"],
         [Authors="Author C,Author D,Author E", #"Author(s) ID"="444123;789012;66666;"],
         [Authors="Author X, Author Y, Author Z, Author P", #"Author(s) ID"="1111;2222;3333;4444;"]}),
    #"Changed Type" = Table.TransformColumnTypes(Source, {{"Authors", type text},{"Author(s) ID", type text}}),

//split each column into a List; trim the entries
    authors = List.Combine(List.Transform(#"Changed Type"[Authors], each Text.Split(Text.Trim(_),","))),
    IDs = List.Combine(List.Transform(#"Changed Type"[#"Author(s) ID"], each Text.Split(Text.Trim(_,";"),";"))),

//create new table
    result = Table.FromColumns({authors,IDs},
                type table[Authors=text, #"Author(s) ID"=text])
in
    result

Result
在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM