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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
subhashg
Frequent Visitor

Creating index bins from repeated instances

Hi,

Looking for a DAX folmula to create below output.

I have sensor status column which changes between 0 & 1s. Need to create a bins (assending numbers) for each time the status turns to 1. I have index column in addition.

Besed on 2nd column I need 3rd column as resultant output. Please help

 

Index    SensorStatus    Bins(Output)

1           0                      0

2           0                      0

3           1                      1

4           1                      1

5           0                      0

6           1                      2

7           1                      2

8           1                      2

9           0                      0

10         0                      0

11         1                      3

12         0                      0

 

1 ACCEPTED SOLUTION

@subhashg , Try new columns

Two new column 

Change = var _1 = minx(filter(Data, [Index] = EARLIER([Index]) -1) ,[SensorStatus]) 
return if([SensorStatus] =1 && _1=0 , 1, 0)

Bin = if([SensorStatus]=1, sumx(FILTER(Data, [Index] <=EARLIER(Data[Index])),[Change]),0)
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@subhashg , This is a Continuous streak ,

 

Streak
https://community.powerbi.com/t5/Desktop/Build-measure-or-column-to-show-a-streak-by-consecutive-dat...
https://community.powerbi.com/t5/Desktop/Win-Losing-Streak/td-p/273547
https://community.powerbi.com/t5/Desktop/Count-last-actual-consecutive-sorted-rows/m-p/151191#M65364

 

I done for dates. see if that can help

Continuous streak : https://youtu.be/GdMcwvdwr0o

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I couldnt see what i really needed in your above post. Please help.

I actually need to increament the Bins everytime SensorStatus turns from 0 to 1 & keep that incremented number untill status turns back to 0.

Status   Bin

0           0

1           1

1           1

0           0

1           2

1           2

1           2

0           0

0           0

1           3     and so on

@subhashg , Try new columns

Two new column 

Change = var _1 = minx(filter(Data, [Index] = EARLIER([Index]) -1) ,[SensorStatus]) 
return if([SensorStatus] =1 && _1=0 , 1, 0)

Bin = if([SensorStatus]=1, sumx(FILTER(Data, [Index] <=EARLIER(Data[Index])),[Change]),0)
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.

Top Solution Authors