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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
jmowen
Frequent Visitor

How to create an index column for each new cycle

Hello,

 

I would like some help with creating a new colunm where an index is given to every new cycle.

A cycle for each ID is complete when Empty = True 

A new cycle starts when Score is added. 

 

Data

IDJobTypeDateScoreFullScore RemovedEmpty
1S1/02/2021500FALSE  
1S2/02/20211500TRUE  
1H5/05/2021  2000TRUE
1S7/08/2021250FALSE  
1S8/08/20211000FALSE  
1S9/08/2021500TRUE  
1H10/12/2021  1000FALSE
1H11/12/2021  750TRUE
1S12/12/20211600TRUE  
2S5/02/2021500FALSE  
2S6/02/20211000TRUE  
2H17/05/2021  1500TRUE
2S19/05/20211500TRUE  
3S1/02/20211750TRUE  
3H4/05/2021  1000FALSE
3H5/05/2021  750TRUE

 

 

Expected Outcome

IDJobTypeDateScoreFullScore RemovedEmptyCycle Index
1S1/02/2021500FALSE  1
1S2/02/20211500TRUE  1
1H5/05/2021  2000TRUE1
1S7/08/2021250FALSE  2
1S8/08/20211000FALSE  2
1S9/08/2021500TRUE  2
1H10/12/2021  1000FALSE2
1H11/12/2021  750TRUE2
1S12/12/20211600TRUE  3
2S5/02/2021500FALSE  4
2S6/02/20211000TRUE  4
2H17/05/2021  1500TRUE4
2S19/05/20211500TRUE  5
3S1/02/20211750TRUE  6
3H4/05/2021  1000FALSE6
3H5/05/2021  750TRUE6

 

This is so I can summerise the data as shown below

IDScoreScore RemovedCycle CompleteCycle Start DateCycle End DateCycle Index
120002000TRUE1/02/20215/05/20211
117501750TRUE7/08/20217/08/20212
1 1600FALSE12/12/2021 3
215001500TRUE5/02/202117/05/20214
2 1500FALSE19/05/2021 5
317501750TRUE1/02/20215/05/20216
1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @jmowen ,

 

Create a index column in Power Query Editor. Then create a calculated column as below:

Column = 
var index2 = CALCULATE(MIN('Table'[Index]),FILTER('Table','Table'[ID]=EARLIER('Table'[ID])&&'Table'[Index]>=EARLIER('Table'[Index])&&'Table'[Empty]=TRUE()))
return
IF(ISBLANK(index2),'Table'[Index],index2)

Then create the Cycle Index like below:

rank_ = RANKX('Table','Table'[Column],,ASC,Dense)

vjaywmsft_0-1655967130637.png

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

1 REPLY 1
v-jayw-msft
Community Support
Community Support

Hi @jmowen ,

 

Create a index column in Power Query Editor. Then create a calculated column as below:

Column = 
var index2 = CALCULATE(MIN('Table'[Index]),FILTER('Table','Table'[ID]=EARLIER('Table'[ID])&&'Table'[Index]>=EARLIER('Table'[Index])&&'Table'[Empty]=TRUE()))
return
IF(ISBLANK(index2),'Table'[Index],index2)

Then create the Cycle Index like below:

rank_ = RANKX('Table','Table'[Column],,ASC,Dense)

vjaywmsft_0-1655967130637.png

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.