Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

GENERATESERIES OVER A GROUP in POWER BI using DAX?

Hi,

 

I have been struggling to understand how to create or transform data from and to (below)-

 

From-

 

UniqueIDMinumumValMaximumValProduct
114A
257B
3811C
41215D

 

TO -

 

UniqueIDValProduct
11A
12A
13A
14A
25B
26B
27B
38C
39C
310C
311C
412D
413D
414D
415D

 

I tried using GenerateSeries but not sure how to loop though and group over UniqueIDs?

1 ACCEPTED SOLUTION
camargos88
Community Champion
Community Champion

Hi @Anonymous ,

 

Try this code on Advanced Editor:

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSAWMTIHZUitWJVjICskyB2ByIncAixkCWBUgdSKEzWAik3BCk0hCk1EUpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [UniqueID = _t, MinumumVal = _t, MaximumVal = _t, Product = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"UniqueID", Int64.Type}, {"MinumumVal", Int64.Type}, {"MaximumVal", Int64.Type}, {"Product", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Diff", each [MaximumVal] - [MinumumVal]),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Diff", type number}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"Diff"}),
#"Added Custom1" = Table.AddColumn(#"Removed Columns", "Generate", each {[MinumumVal]..[MaximumVal]}),
#"Expanded Generate" = Table.ExpandListColumn(#"Added Custom1", "Generate"),
#"Removed Columns1" = Table.RemoveColumns(#"Expanded Generate",{"MinumumVal", "MaximumVal"}),
#"Reordered Columns" = Table.ReorderColumns(#"Removed Columns1",{"UniqueID", "Generate", "Product"}),
#"Renamed Columns" = Table.RenameColumns(#"Reordered Columns",{{"Generate", "Val"}}),
#"Changed Type2" = Table.TransformColumnTypes(#"Renamed Columns",{{"Val", type number}})
in
#"Changed Type2"

Or you can download this example: Sample PBIX 

 

 

Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

1 REPLY 1
camargos88
Community Champion
Community Champion

Hi @Anonymous ,

 

Try this code on Advanced Editor:

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSAWMTIHZUitWJVjICskyB2ByIncAixkCWBUgdSKEzWAik3BCk0hCk1EUpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [UniqueID = _t, MinumumVal = _t, MaximumVal = _t, Product = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"UniqueID", Int64.Type}, {"MinumumVal", Int64.Type}, {"MaximumVal", Int64.Type}, {"Product", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Diff", each [MaximumVal] - [MinumumVal]),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Diff", type number}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"Diff"}),
#"Added Custom1" = Table.AddColumn(#"Removed Columns", "Generate", each {[MinumumVal]..[MaximumVal]}),
#"Expanded Generate" = Table.ExpandListColumn(#"Added Custom1", "Generate"),
#"Removed Columns1" = Table.RemoveColumns(#"Expanded Generate",{"MinumumVal", "MaximumVal"}),
#"Reordered Columns" = Table.ReorderColumns(#"Removed Columns1",{"UniqueID", "Generate", "Product"}),
#"Renamed Columns" = Table.RenameColumns(#"Reordered Columns",{{"Generate", "Val"}}),
#"Changed Type2" = Table.TransformColumnTypes(#"Renamed Columns",{{"Val", type number}})
in
#"Changed Type2"

Or you can download this example: Sample PBIX 

 

 

Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.