Forum Discussion
Sequential Order column based on multiple criteria
I am in need of creating a column "sequential order" that will assign numerical order to each unique subset under the hub. Here's the catch...the hub parent should always be first & not all hubs have subsets. Each subset in the hub gets numbered sequentially. Below is the desired result column "Seq Order". Any help will be greatly appreciated.
| Hub | Hub Name | Subset ID | Subset Name | Seq Order |
| 1 | FW | FW | 0 | |
| 2 | INA | 702 | INA | 0 |
| 2 | INA | 624 | GUAVA | 1 |
| 3 | SB | SB | 0 | |
| 4 | LLLE | 700 | LLLE | 0 |
| 4 | LLLE | 203 | APPLE | 1 |
| 4 | LLLE | 521 | BANANA | 2 |
| 4 | LLLE | 700 | GRAPE | 3 |
| 4 | LLLE | 136 | ORANGE | 4 |
| 4 | LLLE | 953 | PEAR | 5 |
| 4 | LLLE | 630 | MANGO | 6 |
| 4 | LLLE | 631 | PINEAPPLE | 7 |
| 4 | LLLE | 632 | COCONUT | 8 |
| 5 | COL | 028 | COL | 0 |
| 6 | CIN | 609 | CIN | 0 |
| 7 | DTN | DTN | 0 | |
| 8 | MAR | MAR | 0 | |
| 9 | TWI | TWI | 0 | |
| 10 | MID | MID | 0 | |
| 11 | SP | SP | 0 | |
| 12 | PTB | PTB | 0 | |
| 13 | BEC | BEC | 0 | |
| 14 | STO | STO | 0 |
Hi unknown917 , Thank you for reaching out to the Microsoft Community Forum.
From what you said, I assume sequence should restart for each Hub, that the row where Subset Name = Hub Name is the parent and must always be 0 and that all other rows under that Hub are true subsets that should be numbered 1, 2, 3 and so on and that there’s a clear column (like Subset ID) that defines the order of those subsets within each Hub. If so, then please try below DAX:
Seq Order =
VAR _Hub = 'Table'[Hub]
VAR _IsParent =
'Table'[Subset Name] = 'Table'[Hub Name]
RETURN
IF(
_IsParent,
0,
RANKX(
FILTER(
'Table',
'Table'[Hub] = _Hub &&
'Table'[Subset Name] <> 'Table'[Hub Name]
),
'Table'[Subset ID],
,
ASC,
DENSE
)
)If that doesn’t work, then we’d need a small but representative sample of your actual data that fully reproduces the issue, clarification on which column should drive the ordering, confirmation on whether Subset ID is unique within each Hub and any other details that would help us accurately replicate your scenario and give you the correct logic. Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
2 Replies
- Praful_PotphodeSuper User
Hi unknown917 ,
Try below Visual Calculation.
Please find attached Sample PBIX
Please give kudos or mark it as solution once confirmed.
Thanks and Regards,
Praful
LinkedIn - v-hashadapuCommunity Support
Hi unknown917 , Thank you for reaching out to the Microsoft Community Forum.
From what you said, I assume sequence should restart for each Hub, that the row where Subset Name = Hub Name is the parent and must always be 0 and that all other rows under that Hub are true subsets that should be numbered 1, 2, 3 and so on and that there’s a clear column (like Subset ID) that defines the order of those subsets within each Hub. If so, then please try below DAX:
Seq Order =
VAR _Hub = 'Table'[Hub]
VAR _IsParent =
'Table'[Subset Name] = 'Table'[Hub Name]
RETURN
IF(
_IsParent,
0,
RANKX(
FILTER(
'Table',
'Table'[Hub] = _Hub &&
'Table'[Subset Name] <> 'Table'[Hub Name]
),
'Table'[Subset ID],
,
ASC,
DENSE
)
)If that doesn’t work, then we’d need a small but representative sample of your actual data that fully reproduces the issue, clarification on which column should drive the ordering, confirmation on whether Subset ID is unique within each Hub and any other details that would help us accurately replicate your scenario and give you the correct logic. Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...