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
Dicken
Post Patron
Post Patron

Accumulation that re starts at each text value encountered

 
hi,    I have this to   give an accumultion  and re start at each text value so { "A", 2,3,3,"b","c", 3,4,5,"c",2,3, = "A",2,5,8,"b","c",3,7,12
etc. 

 let
       alist = {"A",2,3,3,"a","b",2,3,3,2,"c",3,2,3,2,3}
       in 
         List.Generate(
                        ()=> [x = 0 ,y = alist{0} , z = y] , 
                             each [x] < List.Count( alist) , 
                             each [ x = [x] + 1, y = alist{x} , z = try [z] + y otherwise alist{x}  ],
                             each [z]
                       )

 

 Coult this be written without try / otherwise  and still using generate not accumulate or some other. 

Richard. 

1 ACCEPTED SOLUTION
MarkLaf
Memorable Member
Memorable Member

For your z function, you could check for the type instead:

 

if y is number and [z] is number then [z] + y else y

 

View solution in original post

2 REPLIES 2
Dicken
Post Patron
Post Patron

Thnks, id used Value.Is in  skipping over the text so don't know why I never thought of this.

MarkLaf
Memorable Member
Memorable Member

For your z function, you could check for the type instead:

 

if y is number and [z] is number then [z] + y else y

 

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.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors