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

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

Reply
micjensen
Frequent Visitor

Custom gruping / Indexing - based on multiple criterias/variables

Hi community

 

I'm trying to make a custom grouping/indexing based on various criterias.

I have a table containing data for people and their helicopter flights/departures. A Scheduled flight can be cancelled and the reservation status will then be "Cancelled" and a new scheduled time will be created for that person --> a new row is then created in the table.

I'm really lost on how to do this, when there is so many different variables that has an impact on the result. All tricks, advices and any sort of help would be highly appreciated, thanks a lot in advance.

I want to group/index the table in the following way:

 

 

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @micjensen ,

 

Here are the steps you can follow:

1. In Power Query -- Add Column – Index Column – From 1.

vyangliumsft_0-1674096569729.png

2. Create calculated column.

Flag1 =
var _table=
SUMMARIZE(
    'Table','Table'[Index],"min",MINX(FILTER(ALL('Table'),
'Table'[Index]=EARLIER('Table'[Index])&&'Table'[Reservation Status]<>"Cancelled"),[Index])+1)
var _column=
SELECTCOLUMNS(_table,"min",[min])
var _if1=
IF(
    'Table'[Index] in _column,1,0)
var _if2=
IF(
    'Table'[Index]=
MINX(FILTER(ALL('Table'),'Table'[DaWinci ID]=EARLIER('Table'[DaWinci ID])),[Index]),1,0)
var _if3=
IF(
    _if1=_if2,_if1,_if1+_if2)
return
_if3
Flag2 =
SUMX(FILTER(ALL('Table'),'Table'[Index]<=EARLIER('Table'[Index])),[Flag1])

3. Result:

vyangliumsft_1-1674096569732.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi  @micjensen ,

 

Here are the steps you can follow:

1. In Power Query -- Add Column – Index Column – From 1.

vyangliumsft_0-1674096569729.png

2. Create calculated column.

Flag1 =
var _table=
SUMMARIZE(
    'Table','Table'[Index],"min",MINX(FILTER(ALL('Table'),
'Table'[Index]=EARLIER('Table'[Index])&&'Table'[Reservation Status]<>"Cancelled"),[Index])+1)
var _column=
SELECTCOLUMNS(_table,"min",[min])
var _if1=
IF(
    'Table'[Index] in _column,1,0)
var _if2=
IF(
    'Table'[Index]=
MINX(FILTER(ALL('Table'),'Table'[DaWinci ID]=EARLIER('Table'[DaWinci ID])),[Index]),1,0)
var _if3=
IF(
    _if1=_if2,_if1,_if1+_if2)
return
_if3
Flag2 =
SUMX(FILTER(ALL('Table'),'Table'[Index]<=EARLIER('Table'[Index])),[Flag1])

3. Result:

vyangliumsft_1-1674096569732.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Amazing job - thanks a lot!!!!!!!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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