Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi All,
I'm trying to find the count of the first consecutive negative values
As you see in the image I've selected one ipn and we have projected on-hand values by date I need the count from 19 Dec 2022 to 23 Jan 2023 which is 6 and these are the first consecutive negative values for the projected on-hand.
Can anyone help me with this I need a measure/ calculated column to solve it?
Solved! Go to Solution.
Hi @Pavanace16 ,
According to your description, here are my steps you can follow as a solution.
(1)This is my test data.
(2)We can create a calculated column.
Flag =
MAXX (
FILTER (
'Table',
'Table'[Date] <= EARLIER ('Table'[Date] )
&& 'Table'[Projected On Hand]> 0
),
'Table'[Date]
)
rows =
IF (
'Table'[Projected On Hand] < 0,
COUNTROWS( (
FILTER (
'Table',
'Table'[Projected On Hand]<0
&& 'Table'[Flag]= EARLIER ( 'Table'[Flag] )
)
)
))
(3)We can create a measure.
Measure 2 =
var _a = MINX(FILTER('Table',[Projected On Hand]<0),[Date])
var _b = MINX(FILTER('Table',[Date]>_a&&[Projected On Hand]>=0),[Date])
return CALCULATE(COUNT('Table'[Date]),FILTER('Table',[Date]>=_a&&[Date]<_b))
(3) Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Pavanace16 ,
According to your description, here are my steps you can follow as a solution.
(1)This is my test data.
(2)We can create a calculated column.
Flag =
MAXX (
FILTER (
'Table',
'Table'[Date] <= EARLIER ('Table'[Date] )
&& 'Table'[Projected On Hand]> 0
),
'Table'[Date]
)
rows =
IF (
'Table'[Projected On Hand] < 0,
COUNTROWS( (
FILTER (
'Table',
'Table'[Projected On Hand]<0
&& 'Table'[Flag]= EARLIER ( 'Table'[Flag] )
)
)
))
(3)We can create a measure.
Measure 2 =
var _a = MINX(FILTER('Table',[Projected On Hand]<0),[Date])
var _b = MINX(FILTER('Table',[Date]>_a&&[Projected On Hand]>=0),[Date])
return CALCULATE(COUNT('Table'[Date]),FILTER('Table',[Date]>=_a&&[Date]<_b))
(3) Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
64 | |
55 | |
53 | |
36 | |
34 |
User | Count |
---|---|
85 | |
73 | |
55 | |
45 | |
43 |