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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
idymkowski
New Member

Creating a condition based event counter

I have a dataset with time and inventory levels.  I want to create a counter (within a designated time period) of the # of unique rows where the inventory drops below a specified limit (in this example below 1000).  In the spreadsheet example attached, there are 4 instances I'd like to have triggered.  If I were grouping by hour, there would be one hour with 2 occurances and two hours with 1 occurance each.  Any help would be greatly appreciated.  Beyond this, I'm also going to be interested in calculating the length of time the inventory stayed below the limit.  Thanks in advance.

 

idymkowski_0-1624043391980.png

 

 

4 REPLIES 4
HashamNiaz
Solution Sage
Solution Sage

Hi @idymkowski !

 

You can create a custom column using below DAX;

 

IsBelow = IF(Table[Inverntory] < 1000, 1, 0)

 

This will give you a 1/0 flag whether Inventory is below the limit or not, now you can use this column to create a measure which will sum / count these occurences.

 

BelowLimit = SUM(Inventory[IsBelow])

 

Regards,

Hasham

If I am reading that correctly, it will flag a "1" for each occurance below 1000.  For the first part of my question, I'm only looking for the flag to be there for the 1st record below 1000 (and then reset once the inventory rises above 1000 again).

 

Hi @idymkowski !

 

Got it, please paste sample data for your problem. I have overlooked your initial requirement.

 

Regards,

Hasham

a sample spreadsheet was in the original post.  Do you need more than that?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.