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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
MMPPCP
New Member

Sequence based item combination with grouping attribute

Dear Community,

 

I would like to ask for your help in a transportation related question.

 

Input table: Transport 1 and Transport 2 with the loading/unloading locations and its sequence

 

Transport IDLoading/unloading sequenceZIP code
Transport 10

1230

Transport 113150
Transport 123204
Transport 133240
Transport 143382
Transport 201230
Transport 214405
Transport 224306
Transport 234858

 

 

Expected output: list of all possible transport relations according to transport IDs (as grouping attributes) and given sequence of the locations - see below. The number of options - in case of 4 stops it is 4+3+2+1 = 10; in case of 3 stops it is 3+2+1 = 6.

 

Transport IDTransport relations based on sequence
Transport 11230_3150
Transport 11230_3204
Transport 11230_3240
Transport 11230_3382
Transport 13150_3204
Transport 13150_3240
Transport 13150_3382
Transport 13204_3240
Transport 13204_3382
Transport 13240_3382
Transport 21230_4405
Transport 21230_4306
Transport 21230_4858
Transport 24405_4306
Transport 24405_4858
Transport 24306_4858

 

If anyone could help, I would be really grateful!

 

Best regards,

Peter

1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Hi @MMPPCP -Create a new table in Power BI that lists the transport data as below:

TransportRelations =

VAR TransportTable1 =
    SELECTCOLUMNS(
        'transp',
        "TransportID1", 'transp'[Transport ID],
        "Seq1", 'transp'[Loading/unloading sequence],
        "ZIP1", 'transp'[ZIP code]
    )
VAR TransportTable2 =
    SELECTCOLUMNS(
        'transp',
        "TransportID2", 'transp'[Transport ID],
        "Seq2", 'transp'[Loading/unloading sequence],
        "ZIP2", 'transp'[ZIP code]
    )
RETURN
    SELECTCOLUMNS(
        FILTER(
            CROSSJOIN(TransportTable1, TransportTable2),
            [TransportID1] = [TransportID2] && [Seq1] < [Seq2]
        ),
        "Transport ID", [TransportID1],
        "Transport relation", [ZIP1] & "_" & [ZIP2]
    )
 

rajendraongole1_0-1726853020218.png

 

Hope this works 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

2 REPLIES 2
rajendraongole1
Super User
Super User

Hi @MMPPCP -Create a new table in Power BI that lists the transport data as below:

TransportRelations =

VAR TransportTable1 =
    SELECTCOLUMNS(
        'transp',
        "TransportID1", 'transp'[Transport ID],
        "Seq1", 'transp'[Loading/unloading sequence],
        "ZIP1", 'transp'[ZIP code]
    )
VAR TransportTable2 =
    SELECTCOLUMNS(
        'transp',
        "TransportID2", 'transp'[Transport ID],
        "Seq2", 'transp'[Loading/unloading sequence],
        "ZIP2", 'transp'[ZIP code]
    )
RETURN
    SELECTCOLUMNS(
        FILTER(
            CROSSJOIN(TransportTable1, TransportTable2),
            [TransportID1] = [TransportID2] && [Seq1] < [Seq2]
        ),
        "Transport ID", [TransportID1],
        "Transport relation", [ZIP1] & "_" & [ZIP2]
    )
 

rajendraongole1_0-1726853020218.png

 

Hope this works 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Dear @rajendraongole1 ,

 

thank you very much, it works perfect.

 

Best regards,

Peter

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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