Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
How do I create a colum (B) that starts at "1" and increments when column A changes? 🙂
Solved! Go to Solution.
Hi @Anonymous ,
if you group on ColumnA/Week Number with GroupKind.Local and select "All Rows" in the aggregation, you'll get a table where you simply add an index column to. Then expand the grouped columns again:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjVUitVBUEZgyhCDNIKRsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Week number1" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Week number1", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Week number1"}, {{"All", each _, type table [Week number1=nullable number]}}, GroupKind.Local),
#"Added Index" = Table.AddIndexColumn(#"Grouped Rows", "Group", 1, 1, Int64.Type),
#"Removed Columns" = Table.RemoveColumns(#"Added Index",{"Week number1"}),
#"Expanded All" = Table.ExpandTableColumn(#"Removed Columns", "All", {"Week number1"}, {"Week number"})
in
#"Expanded All"
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
here you can find some solutions(some of which are very similar to the one proposed here ) to identical problem
Thank you I appreciate the links.
Hi @Anonymous ,
if you group on ColumnA/Week Number with GroupKind.Local and select "All Rows" in the aggregation, you'll get a table where you simply add an index column to. Then expand the grouped columns again:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjVUitVBUEZgyhCDNIKRsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Week number1" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Week number1", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Week number1"}, {{"All", each _, type table [Week number1=nullable number]}}, GroupKind.Local),
#"Added Index" = Table.AddIndexColumn(#"Grouped Rows", "Group", 1, 1, Int64.Type),
#"Removed Columns" = Table.RemoveColumns(#"Added Index",{"Week number1"}),
#"Expanded All" = Table.ExpandTableColumn(#"Removed Columns", "All", {"Week number1"}, {"Week number"})
in
#"Expanded All"
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.