March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Expected Outcome
I have tried using the following M-Code, however I think there is an easy way or short way to do this.
let
Source = Excel.CurrentWorkbook(){[Name="Table4"]}[Content],
#"Grouped Rows" = Table.Group(Source, {"Name"}, {{"All", each _, type table [Name=text, States=text, State Code=text]}, {"Sum", each Text.Combine([State Code],"; "), type text}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([All],"Index",1,1)),
#"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"States", "State Code", "Index"}, {"States", "State Code", "Index"}),
#"Added Conditional Column" = Table.AddColumn(#"Expanded Custom", "Result", each if [Index] = 1 then [Sum] else null),
#"Removed Columns" = Table.RemoveColumns(#"Added Conditional Column",{"All", "Sum", "Index"})
in
#"Removed Columns"
Solved! Go to Solution.
Hi @Anonymous ,
Here the code in Power Query M that you can paste into the advanced editor (if you do not know, how to exactly do this, please check out this quick walkthrough)
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fY/BCsIwDIbfpee9RDcPG4p4duzwSwcL1BSiQ93T2xYmlBRP/dsv+ZqMo2mFwAzTmIFdjDmdzdQUyHviQI8UT5kd8fEUr9bjhnuqsSVQth9QLuvnN9gJar4CCm0hO+1VwcFhCek8KNTjBUp/94Nu+zuO2qJbsFW7dlBOccEaC6uLdZDnLFVXKysHLdufi3WmLw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, States = _t, #"State Code" = _t]),
#"Grouped Rows" = Table.Group(Source, {"Name"}, {{"All", each _, type table [Name=text, States=text, State Code=text]}, {"Result", each Text.Combine([State Code],"; "), type text}}),
#"Expanded All" = Table.ExpandTableColumn( Table.TransformColumns(#"Grouped Rows",{ "All", each Table.FirstN(_,1)}) , "All", {"States"}, {"All.States"}),
#"Merged Queries" = Table.NestedJoin(Source, {"Name", "States"}, #"Expanded All", {"Name", "All.States"}, "Expanded All", JoinKind.LeftOuter),
#"Expanded Expanded All" = Table.ExpandTableColumn(#"Merged Queries", "Expanded All", {"Result"}, {"Result"})
in
#"Expanded Expanded All"
Let me know if this one works foru you 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
Did I answer your question❓➡️ Please, mark my post as a solution ✔️ |
Also happily accepting Kudos 🙂 |
Feel free to connect with me on LinkedIn! |
#proudtobeasuperuser |
Hi @tackytechtom yes it worked very well, if I can ask, what is this line
Json.Document(Binary.Decompress(Binary.FromText("fY/BCsIwDIbfpee9RDcPG4p4duzwSwcL1BSiQ93T2xYmlBRP/dsv+ZqMo2mFwAzTmIFdjDmdzdQUyHviQI8UT5kd8fEUr9bjhnuqsSVQth9QLuvnN9gJar4CCm0hO+1VwcFhCek8KNTjBUp/94Nu+zuO2qJbsFW7dlBOccEaC6uLdZDnLFVXKysHLdufi3WmLw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, States = _t, #"State Code" = _t]),
Hi @Anonymous ,
That line is created by Power Query when you manually enter data.
Great that it helped!
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
Did I answer your question❓➡️ Please, mark my post as a solution ✔️ |
Also happily accepting Kudos 🙂 |
Feel free to connect with me on LinkedIn! |
#proudtobeasuperuser |
Hi @Anonymous ,
Here the code in Power Query M that you can paste into the advanced editor (if you do not know, how to exactly do this, please check out this quick walkthrough)
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fY/BCsIwDIbfpee9RDcPG4p4duzwSwcL1BSiQ93T2xYmlBRP/dsv+ZqMo2mFwAzTmIFdjDmdzdQUyHviQI8UT5kd8fEUr9bjhnuqsSVQth9QLuvnN9gJar4CCm0hO+1VwcFhCek8KNTjBUp/94Nu+zuO2qJbsFW7dlBOccEaC6uLdZDnLFVXKysHLdufi3WmLw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, States = _t, #"State Code" = _t]),
#"Grouped Rows" = Table.Group(Source, {"Name"}, {{"All", each _, type table [Name=text, States=text, State Code=text]}, {"Result", each Text.Combine([State Code],"; "), type text}}),
#"Expanded All" = Table.ExpandTableColumn( Table.TransformColumns(#"Grouped Rows",{ "All", each Table.FirstN(_,1)}) , "All", {"States"}, {"All.States"}),
#"Merged Queries" = Table.NestedJoin(Source, {"Name", "States"}, #"Expanded All", {"Name", "All.States"}, "Expanded All", JoinKind.LeftOuter),
#"Expanded Expanded All" = Table.ExpandTableColumn(#"Merged Queries", "Expanded All", {"Result"}, {"Result"})
in
#"Expanded Expanded All"
Let me know if this one works foru you 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
Did I answer your question❓➡️ Please, mark my post as a solution ✔️ |
Also happily accepting Kudos 🙂 |
Feel free to connect with me on LinkedIn! |
#proudtobeasuperuser |
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.