Forum Discussion

Mechi's avatar
Mechi
Helper I
6 years ago
Solved

Create New table based on the selected existing table column headers

Hello,

 I need a small help in creating new tables based on the column headers of existing table

 

For example if i have the following existing table

NumberT1T2T3Avl
5645X XY
3241 XXY
7592   N
1643  XY
2549X  Y
4759   N
6247XX Y
8713 X Y
9437 X N

 

I need a new table with the selected column headers from the existing table as follows

 

T_ID
T1
T2
T3

 

BR

Mechi ğŸ”§

  • Don't think you can extract Column Names in separate table using DAX. May be someone else be able to help.

4 Replies

  • AnkitBI's avatar
    AnkitBI
    Solution Sage

    Mechi Try Below

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Zc3BCcAwCIXhXTznEn1qs0TPLSH7r9HQFG0pRIQP+dM7qUGp0DHnWSeN0kkYNS3dtfHy9fZbq0GC8pgVLePBmJF/wxj++i6uN6+S4eAG8Q/PyrgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Number = _t, T1 = _t, T2 = _t, T3 = _t, Avl = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Number", Int64.Type}, {"T1", type text}, {"T2", type text}, {"T3", type text}, {"Avl", type text}}),
        Custom1 = List.Select(Table.ColumnNames(#"Changed Type"),each Text.StartsWith(_,"T")),
        #"Converted to Table" = Table.FromList(Custom1, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
    in
        #"Converted to Table"

     

    Thanks
    Ankit Jain
    Do Mark it as solution if the response resolved your problem. Do Kudo the response if it seems good and helpful.

    • Mechi's avatar
      Mechi
      Helper I

      AnkitBI , Thanks for the Code

      But i needs to create this table outside of Edit Query, Would be great help if i can able to do this in Modelling --> New Table using DAX formulas

       

      BR

      Mechi ğŸ”§

      • AnkitBI's avatar
        AnkitBI
        Solution Sage
        Don't think you can extract Column Names in separate table using DAX. May be someone else be able to help.