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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Pete230
Helper III
Helper III

Create a costum column which counts consecutive negative numbers

Hi together;

I would like to create a costum column C in power querry which counts the consecutive negative numbers in Column B.
Which forml needs to be put in here:

Pete230_0-1719937755327.png



to achive the following goal (result in column c)

BC
80
50
-53
-473
-43
10
50


Thanks and regards

Pete

3 REPLIES 3
Pete230
Helper III
Helper III

Dear @v-jialongy-msft ,

 

thanks for the quick reply; unfortunatly i get an error saying can not be converted into a list:

Pete230_1-1719991304538.png

 

my table and datatypes are the following:




Pete230_0-1719991268523.png

Any idea how to solve that?

Cheers, Pete

v-jialongy-msft
Community Support
Community Support

Hi @Pete230 

 

First, add an index column in power query.

Then use the following code to add a custom column:

let
CurrentRow = [Index],
ListNegative = List.LastN(
                List.FirstN(Source[B], CurrentRow+1),
                each Number.FromText(_) < 0
            )
in 
List.Count(ListNegative)

 

 

 

Best Regards,

Jayleny

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-jialongy-msft ; do you have any advice for that issue too?
That would be very much appreciated 🙂

Cheers, Pete

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.