I am in this screen:
The data looks like this:
\\asdhf\revi\Tim2,AK\AK_ADMPH,Allow,Fix
\\asdfs1\revi\Tim, John,BUILTIN\Administrators,Allow,None
I want to use “dynamic” delimiters… I want the delimiters to be:
1st delimiter: “,BUILTIN” and “,AK”
Then: the usual comma.
The end result should be:
I have tried many ways with no success.
You can't do that from that screen but you can achieve what you want with a two step split. e.g.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WiolJLE7JSIuJKUoty4yJCcnMNdJx9I6JcfSOd3TxDfDQcczJyS/XccusUIrVgSpPKzZEUq+j4JWfkafjFOrpE+LpB9SZkpuZl1lcUpRYkl9UDNXvl5+XqhQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Column1", Splitter.SplitTextByAnyDelimiter({",BUILTIN", ",AK"}, QuoteStyle.Csv, false), {"Column1.1", "Column1.2"}),
#"Split Column by Delimiter1" = Table.SplitColumn(#"Split Column by Delimiter", "Column1.2", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Column1.2.1", "Column1.2.2", "Column1.2.3"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"Column1.1", type text}, {"Column1.2.1", type text}, {"Column1.2.2", type text}, {"Column1.2.3", type text}})
in
#"Changed Type1"
Related
I have many columns of same table
Table A
Monthly Plan
Weekly plan
Actual
Monthly_Plan1
Weekly_plan 2
Actual_3
A
B
C
D
E
F
I want them as :
Monthly Plan
Weekly plan
Actual
A
B
C
D
E
F
I can not create a separate table and append it because there are so many columns and I cant create too many tables.
Here you go.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclRQ0lFyAhHOIMIFRLiCCDel2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Monthly Plan " = _t, #"Weekly plan " = _t, #"Actual " = _t, #"Monthly_Plan1 " = _t, #"Weekly_plan 2 " = _t, Actual_3 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Monthly Plan ", type text}, {"Weekly plan ", type text}, {"Actual ", type text}, {"Monthly_Plan1 ", type text}, {"Weekly_plan 2 ", type text}, {"Actual_3", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Split( Record.ToList( _), 3)),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Custom"}),
#"Expanded Custom" = Table.ExpandListColumn(#"Removed Other Columns", "Custom"),
#"Extracted Values" = Table.TransformColumns(#"Expanded Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), "|"), type text}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Extracted Values", "Custom", Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv), {"Monthly", "Weekly", "Actual"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Monthly", type text}, {"Weekly", type text}, {"Actual", type text}})
in
#"Changed Type1"
Add a custom column
Remove other columns
Expand
Extract values concatenating with a |
Split the column and rename
If you don't care about row order this also works
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Combo = List.Split(Table.ColumnNames(Source),3),
#"Added Custom" =List.Accumulate(Combo, #table({"Column1"}, {}),(state,current)=> state & Table.Skip(Table.DemoteHeaders(Table.SelectColumns(Source, current)),1))
in #"Added Custom"
I am using power query in Excel. I have following table generated from a raw SQL query.
ABC_MONTH
ABC_YEAR
XYZ_MONTH
XYZ_YEAR
10
20
30
40
I would like to transform the above table into the following one in power query or tansformations. Kindly help.
NAME
MONTH
YEAR
ABC
10
20
XYZ
30
40
First unpivot all the columns to get this:
Split the Attribute column by the left-most underscore:
To get this:
Then pivot Attribute.2 and Value:
To get the desired output (after renaming Attribute.1 to NAME):
The M code to try:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjRQ0lEyAhHGIMLEQCk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ABC_MONTH = _t, ABC_YEAR = _t, XYZ_MONTH = _t, XYZ_YEAR = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ABC_MONTH", Int64.Type}, {"ABC_YEAR", Int64.Type}, {"XYZ_MONTH", Int64.Type}, {"XYZ_YEAR", Int64.Type}}),
#"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {}, "Attribute", "Value"),
#"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Columns", "Attribute", Splitter.SplitTextByEachDelimiter({"_"}, QuoteStyle.Csv, false), {"Attribute.1", "Attribute.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", type text}, {"Attribute.2", type text}}),
#"Pivoted Column" = Table.Pivot(#"Changed Type1", List.Distinct(#"Changed Type1"[Attribute.2]), "Attribute.2", "Value", List.Sum),
#"Renamed Columns" = Table.RenameColumns(#"Pivoted Column",{{"Attribute.1", "NAME"}})
in
#"Renamed Columns"
I am trying to change the format of a column from text to time in Power Bi:
When I change the format to time, anything that is over 24 hours shows as an error:
Does anyone know how to resolve this?
You can try this below Advanced Editor code for your purpose.
Conditions Values like (73:30) required a delimiter : for this code. You can also adjust the code if different delimiter in use.
Output will in dd:hh:mm:ss
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjSwMjBQitWJVjKGs8yNrYyBrFgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Time = _t]),
#"Duplicated Column" = Table.DuplicateColumn(Source, "Time", "Time - Copy"),
#"Split Column by Delimiter" = Table.SplitColumn(#"Duplicated Column", "Time - Copy", Splitter.SplitTextByDelimiter(":", QuoteStyle.Csv), {"Time - Copy.1", "Time - Copy.2"}),
#"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Time", type text}, {"Time - Copy.1", Int64.Type}, {"Time - Copy.2", Int64.Type}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Time - Copy.1", "hour"}, {"Time - Copy.2", "minutes"}}),
#"Added Custom" = Table.AddColumn(#"Renamed Columns", "Second", each ([hour]*60*60) + ([minutes]*60)),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom", each #duration(0,0,0,[Second])),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom1",{{"Custom", type duration}})
in
#"Changed Type1"
Input-
Output-
Hope you are staying safe. I have a column in my powerbi report dataset which holds list values in a column.
Id Name
1 kevin,yona,rachel,kevin
2 bruce,miller,kim
3 adam,rita,adam,adam
As you can see there are duplicate values in the list on Name column. I wanted to write a query which will remove those duplicates and and keep one occurences. the result set i want is like this
Id Name
1 yona,rachel,kevin
2 bruce,miller,kim
3 adam,rita
Any ideas? thanks
You could split, remove duplicates and group by again.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Hck7CoBADIThu6SeRj1O2CKuAcO+IKjg7V3TDD/zMdNCoKKPdbyjC1zyqRXxUALTOn33Oyua1aqOYi1gmyCHNLhdgqh/KKUP", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}, {"Column2", type text}}),
#"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Changed Type", {{"Column2", Splitter.SplitTextByDelimiter(",", QuoteStyle.None), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Column2"),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column2", type text}}),
#"Removed Duplicates" = Table.Distinct(#"Changed Type1"),
#"Grouped Rows" = Table.Group(#"Removed Duplicates", {"Column1"}, {{"Rows", each _, type table [Column1=number, Column2=text]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each [Rows][Column2]),
#"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
#"Removed Columns" = Table.RemoveColumns(#"Extracted Values",{"Rows"})
in
#"Removed Columns"
My table looks like this:
I want it to look like this:
I did it with :
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfL0s/b0sQ4NBjIDnK1DEpNyUkusAzLy81KBIkZAbKwUqxMNZoUGW3v6AWk0RaZghbGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t, market = _t, device = _t, userCount = _t, Num = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"market", type text}, {"device", type text}, {"userCount", Int64.Type}}), #"Transposed Table" = Table.Transpose(#"Changed Type"), #"Split Column by Delimiter" = Table.SplitColumn(Table.TransformColumnTypes(#"Transposed Table", {{"Column1", type text}}, "en-US"),"Column1",Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv),{"Column1.1", "Column1.2", "Column1.3"}), #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.1", type text}, {"Column1.2", type text}, {"Column1.3", type text}}), #"Split Column by Delimiter1" = Table.SplitColumn(Table.TransformColumnTypes(#"Changed Type1", {{"Column2", type text}}, "en-US"),"Column2",Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv),{"Column2.1", "Column2.2"}), #"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"Column2.1", type text}, {"Column2.2", type text}}), #"Transposed Table1" = Table.Transpose(#"Changed Type2"), #"Filled Down" = Table.FillDown(#"Transposed Table1",{"Column3", "Column4", "Column5", "Column1"}), #"Changed Type3" = Table.TransformColumnTypes(#"Filled Down",{{"Column4", Int64.Type}, {"Column5", Int64.Type}}), #"Renamed Columns" = Table.RenameColumns(#"Changed Type3",{{"Column1", "ID"}, {"Column2", "Market"}, {"Column3", "Device"}, {"Column4", "UserCount"}, {"Column5", "Num"}}) in #"Renamed Columns"
I wanted to split the multiple columns, by saving the order of each value with the semicolon:
USERCOUNT of IN and PC is 2
USERCOUNT of Us and Tablet is 5
USERCOUNT US and PC is blank
This code is easy when you have 2 rows transposed to 2 columns but what if I don't know how many rows I have?
I want to create a loop to do the function on each column (after first transposed).
you can use this code which provides a dynamic solution:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfL0s/b0sQ4NBjIDnK1DEpNyUkusAzLy81KBIkZAbKwUqxMNZoUGW3v6AWk0RaZghbGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t, market = _t, device = _t, userCount = _t, Num = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"market", type text}, {"device", type text}, {"userCount", Int64.Type}}),
ToLists = Table.TransformColumns(#"Changed Type",{{"market", each Text.Split(_, ";")}, {"device", each Text.Split(_, ";")}}),
#"Added Custom" = Table.AddColumn(ToLists, "Custom", each Table.FromColumns({[market], [device]})),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"market", "device"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Columns", "Custom", {"Column1", "Column2"}, {"Market", "Device"})
in
#"Expanded Custom"