Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
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
| ID | TASK | PROD |
| 0 | 1 | -100 |
| 0 | 1 | -50 |
| 0 | 1 | -20 |
| 0 | 1 | 10 |
| 0 | 1 | 40 |
| 0 | 1 | 100 |
| 11 | 3 | -50 |
| 11 | 3 | -10 |
| 11 | 3 | 20 |
| 11 | 3 | -2 |
| 11 | 3 | -10 |
| 11 | 3 | 10 |
| 5 | 2 | -50 |
| 5 | 2 | -8 |
| 5 | 2 | 20 |
| 5 | 2 | -5 |
| 5 | 2 | 30 |
Solved! Go to Solution.
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
_getfirstnegto get this
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
Proud to be a Super User!
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
_getfirstnegto get this
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
Proud to be a Super User!
Hi @OscarSuarez10 ,
When you say the first negative number, are you looking for the highest negative number?
Nathaniel
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
Proud to be a Super User!
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 9 | |
| 5 | |
| 4 | |
| 3 | |
| 3 |
| User | Count |
|---|---|
| 24 | |
| 12 | |
| 11 | |
| 9 | |
| 8 |