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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Dicken
Responsive Resident
Responsive Resident

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
Super User
Super User

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
Responsive Resident
Responsive Resident

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

MarkLaf
Super User
Super User

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors