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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
OscarSuarez10
Helper III
Helper III

Fitst Negative number before the first positive number

Hello How can I get the first negative number  for each ID and Task before the first positive number like in the following table?

 

ID: 0 TASK: 1 First negative number before first positive number = -20

ID: 11 TASK: 3  First negative number before first positive number = -10

ID: 5 TASK: 2  First negative number before first positive number = -8

 

IDTASKPROD
01-100
01-50
01-20
0110
0140
01100
113-50
113-10
11320
113-2
113-10
11310
52-50
52-8
5220
52-5
5230

 

1 ACCEPTED SOLUTION
Nathaniel_C
Community Champion
Community Champion

Hi @OscarSuarez10 ,

You will need to go to Power Query and add a index column.

Then

Get pos =
VAR _getfirstpos =
    CALCULATE (
        MIN ( Neg[Index] ),
        FILTER ( ALLEXCEPT ( Neg, Neg[ID], Neg[TASK] ), Neg[PROD] > 0 )
    )
VAR _getfirstneg =
    CALCULATE (
        MAX ( Neg[PROD] ),
        FILTER ( ALLEXCEPT ( Neg, Neg[ID], Neg[TASK] ), Neg[Index] < _getfirstpos )
    )
RETURN
    _getfirstneg

to get this get pos.PNG

 

 
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

4 REPLIES 4
Nathaniel_C
Community Champion
Community Champion

Hi @OscarSuarez10 ,

You will need to go to Power Query and add a index column.

Then

Get pos =
VAR _getfirstpos =
    CALCULATE (
        MIN ( Neg[Index] ),
        FILTER ( ALLEXCEPT ( Neg, Neg[ID], Neg[TASK] ), Neg[PROD] > 0 )
    )
VAR _getfirstneg =
    CALCULATE (
        MAX ( Neg[PROD] ),
        FILTER ( ALLEXCEPT ( Neg, Neg[ID], Neg[TASK] ), Neg[Index] < _getfirstpos )
    )
RETURN
    _getfirstneg

to get this get pos.PNG

 

 
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Nathaniel_C
Community Champion
Community Champion

Hi @OscarSuarez10 ,

When you say the  first negative number, are you looking for the highest negative number?

Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @Nathaniel_C  no, I am looking for the first negative number that appears immediatly before the first positive number according to the Product column

 

Ok, I figured that.  How does that solution work for you? Nathaniel

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.