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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
CrazyFrog
Frequent Visitor

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors