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

View all the Fabric Data Days sessions on demand. View schedule

Reply
RalphO
Helper I
Helper I

Count of change of values from x to y

Hey!

 

I've got the following data: 

timestate
2018-07-27 03:35:33.00000004
2018-07-27 03:35:35.00000004
2018-07-27 03:35:37.00000004
2018-07-27 03:35:39.00000004
2018-07-27 03:35:41.00000005
2018-07-27 03:35:43.00000005
2018-07-27 03:35:45.00000004
2018-07-27 03:35:47.00000004
2018-07-27 03:35:49.00000004
2018-07-27 03:35:51.00000006
2018-07-27 03:35:53.00000006
2018-07-27 03:35:55.00000006
2018-07-27 03:35:57.00000006
2018-07-27 03:35:59.00000004
2018-07-27 03:36:01.00000004
2018-07-27 03:36:03.00000006
2018-07-27 03:36:05.00000006

 

Now, i want to count how many times the state changes from 4 to 6. So the answer for this particular sample should be 2. NOTE: this has to be done with a measure, since I can not currently create calculated columns for my data set. 

 

Is this at all possible? And if yes, how do I do this??

 

Thanks in advance!

 

Ralph 

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @RalphO,

 

We can create the measures as below to achieve your goal.

 

 

rank = RANKX(ALLSELECTED(Table1),CALCULATE(MAX(Table1[time])),,ASC,Dense)
Measure = var pl = [rank]+1 
var sta = MAX(Table1[state])
return IF(sta=4 &&
CALCULATE(MAX(Table1[state]),FILTER(ALLSELECTED(Table1),[rank]=pl))=6,1,0)
result = SUMX(Table1,[Measure])

Capture.PNG

 

For more details, please check the pbix as attached.

 

Regards,

Frank

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @RalphO,

 

We can create the measures as below to achieve your goal.

 

 

rank = RANKX(ALLSELECTED(Table1),CALCULATE(MAX(Table1[time])),,ASC,Dense)
Measure = var pl = [rank]+1 
var sta = MAX(Table1[state])
return IF(sta=4 &&
CALCULATE(MAX(Table1[state]),FILTER(ALLSELECTED(Table1),[rank]=pl))=6,1,0)
result = SUMX(Table1,[Measure])

Capture.PNG

 

For more details, please check the pbix as attached.

 

Regards,

Frank

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

That works, thank you!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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
Top Kudoed Authors