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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. 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

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.