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.
Hi, I need to group by consecutive numbers (groups of 3), starting from the latest (in this example the first group would be 34,33,32), I need to named the group as the latest number.
This list is going to get bigger over the future months.
How can I achieve this in Power Query?
Solved! Go to Solution.
Hi @Anonymous ,
Try this:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Tc/JCcAwEEPRXuZs8CxeazHpv42EaEC+PnTQP0dcXeuqJkVayFNSJsQpA2KUDlFK+yU2JSCL4pBJMchIsV0tR/2iXLWLFBSkDXEK0sIoSAulIM2/288L", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Month = _t, Index = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Month", type date}, {"Index", Int64.Type}}),
#"Sorted Rows" = Table.Sort(#"Changed Type",{{"Index", Order.Descending}}),
#"Add Index Group" = Table.Group(#"Sorted Rows","Index",{"IndexGroup",each _},0,(x,y)=>Number.From(Number.Mod(y,3)=1)),
#"Expanded IndexGroup" = Table.ExpandTableColumn(#"Add Index Group", "IndexGroup", {"Month", "Index"}, {"Month", "Index.1"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded IndexGroup",{{"Index", Int64.Type}, {"Month", type date}, {"Index.1", Int64.Type}})
in
#"Changed Type1"
Note: it is needed to sort the index column by Descending.
Best regards
Icey
If this post helps, then consider Accepting it as the solution to help other members find it faster.
Hi @Anonymous ,
Try this:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Tc/JCcAwEEPRXuZs8CxeazHpv42EaEC+PnTQP0dcXeuqJkVayFNSJsQpA2KUDlFK+yU2JSCL4pBJMchIsV0tR/2iXLWLFBSkDXEK0sIoSAulIM2/288L", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Month = _t, Index = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Month", type date}, {"Index", Int64.Type}}),
#"Sorted Rows" = Table.Sort(#"Changed Type",{{"Index", Order.Descending}}),
#"Add Index Group" = Table.Group(#"Sorted Rows","Index",{"IndexGroup",each _},0,(x,y)=>Number.From(Number.Mod(y,3)=1)),
#"Expanded IndexGroup" = Table.ExpandTableColumn(#"Add Index Group", "IndexGroup", {"Month", "Index"}, {"Month", "Index.1"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded IndexGroup",{{"Index", Int64.Type}, {"Month", type date}, {"Index.1", Int64.Type}})
in
#"Changed Type1"
Note: it is needed to sort the index column by Descending.
Best regards
Icey
If this post helps, then consider Accepting it as the solution to help other members find it faster.
@Anonymous so your example is a bit confusing, so the latest value is 43 and you want to take that as a base and group backward in groups of 3, is this what you are after?
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@Anonymous what is the logic to group 32/33/34 together? What is the pattern?
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi, the logic is that I need to create dynamic quarters. I need to group those months by three , starting from the latest.
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.
User | Count |
---|---|
109 | |
106 | |
87 | |
75 | |
66 |
User | Count |
---|---|
125 | |
114 | |
98 | |
81 | |
73 |