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

Certain number of index values for dynamic number of rows

Hello,

I am currently trying to implement the following: I have given the following table with a dynamic number of scenarios and their corresponding AddValue values. 

Annotation 2024-01-25 120547.png

Now I am trying to insert indices from 0 to 15 for each scenario (see screenshots from excel example):

Annotation 2024-01-25 120731.png

I am grateful for any help. Thanks in advance!

 

 

1 ACCEPTED SOLUTION
collinsg
Super User
Super User

Hi CrazyFrog,

An approach is to,

  1. Add a column "Index" containing a list 0-15 for each row.
  2. Expand the list to rows.

Here is example code,

let
Source = Excel.CurrentWorkbook(){[Name="tbl"]}[Content],
#"Added Index List" = Table.AddColumn(Source, "Index", each List.Numbers(0,16,1)),
#"Expanded Index List" = Table.ExpandListColumn(#"Added Index List", "Index"),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded Index List",{{"Index", Int64.Type}, {"Add Value", Int64.Type}, {"Scenario", Int64.Type}})
in
#"Changed Type"

yielding,

 

collinsg_0-1706181753697.png

 

View solution in original post

1 REPLY 1
collinsg
Super User
Super User

Hi CrazyFrog,

An approach is to,

  1. Add a column "Index" containing a list 0-15 for each row.
  2. Expand the list to rows.

Here is example code,

let
Source = Excel.CurrentWorkbook(){[Name="tbl"]}[Content],
#"Added Index List" = Table.AddColumn(Source, "Index", each List.Numbers(0,16,1)),
#"Expanded Index List" = Table.ExpandListColumn(#"Added Index List", "Index"),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded Index List",{{"Index", Int64.Type}, {"Add Value", Int64.Type}, {"Scenario", Int64.Type}})
in
#"Changed Type"

yielding,

 

collinsg_0-1706181753697.png

 

Helpful resources

Announcements
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.

May 2025 Monthly Update

Fabric Community Update - May 2025

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

Top Solution Authors