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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
MrNoob
Helper II
Helper II

Búsqueda de conexiones aéreas

Estoy perdido aquí. Estoy tratando de encontrar las conexiones para los pares de origen y destino. En este ejemplo DEN-ORD, me gustaría devolver DEN-ATL-ORD y así sucesivamente?

¿Es esto posible?

Gracias por la ayuda:)

O&DOrigenDestino
DEN-ATLelAtl
DEN-DTWelDtw
LA PALABRAelPalabra
DTW-DENDtwel
DTW-ORDDtwPalabra
ATL-ORDAtlPalabra
1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hola @MrNoob ,

Prueba esto:

1. Cree dos tablas.

Origin = VALUES('Table'[Origin])
Destination = VALUES('Table'[Destination])

re.JPG

2. Cree segmentaciones de datos.

slicer.gif

3. Cree una medida.

Measure =
VAR Origin_ =
    SELECTEDVALUE ( Origin[Origin] )
VAR Destination_ =
    SELECTEDVALUE ( Destination[Destination] )
VAR t1 =
    SELECTCOLUMNS (
        FILTER ( 'Table', 'Table'[Origin] = Origin_ ),
        "Origin1", [Origin],
        "Destination1", [Destination]
    )
VAR t2 =
    SELECTCOLUMNS (
        FILTER ( 'Table', 'Table'[Destination] = Destination_ ),
        "Origin2", [Origin],
        "Destination2", [Destination]
    )
VAR t3 =
    FILTER (
        CROSSJOIN ( t1, t2 ),
        [Destination1] = [Origin2]
            || [Destination1] = Destination_
    )
VAR t4 =
    SUMMARIZE (
        t3,
        [Origin1],
        [Destination1],
        [Destination2],
        "O&D_",
            IF (
                [Destination1] = Destination_,
                [Origin1] & "-" & [Destination1],
                [Origin1] & "-" & [Destination1] & "-" & [Destination2]
            )
    )
RETURN
    CONCATENATEX ( t4, [O&D_], "," & UNICHAR ( 10 ) & " " )

od.gif

BTW, archivo .pbix adjunto.

Saludos

Icey

Si este post ayuda,entonces considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

View solution in original post

3 REPLIES 3
akay23
Helper I
Helper I

Hola, usé tu solución para mi informe. Funciona bien. Pero quiero calcular el tiempo total de vuelo.
Por ejemplo,

O&DOrigenDestinoHora de salidaHora de llegada
DEN-ATLelAtl12:0015:00
DEN-DTWelDtw
LA PALABRAelPalabra
DTW-DENDtwel08:0010:00
DTW-ORDDtwPalabra
ATL-ORDAtlPalabra

Quiero el tiempo total de vuelo DTW - DEN - ATL a las 7:00

¿Puede ser?

Gracias.

Icey
Community Support
Community Support

Hola @MrNoob ,

Prueba esto:

1. Cree dos tablas.

Origin = VALUES('Table'[Origin])
Destination = VALUES('Table'[Destination])

re.JPG

2. Cree segmentaciones de datos.

slicer.gif

3. Cree una medida.

Measure =
VAR Origin_ =
    SELECTEDVALUE ( Origin[Origin] )
VAR Destination_ =
    SELECTEDVALUE ( Destination[Destination] )
VAR t1 =
    SELECTCOLUMNS (
        FILTER ( 'Table', 'Table'[Origin] = Origin_ ),
        "Origin1", [Origin],
        "Destination1", [Destination]
    )
VAR t2 =
    SELECTCOLUMNS (
        FILTER ( 'Table', 'Table'[Destination] = Destination_ ),
        "Origin2", [Origin],
        "Destination2", [Destination]
    )
VAR t3 =
    FILTER (
        CROSSJOIN ( t1, t2 ),
        [Destination1] = [Origin2]
            || [Destination1] = Destination_
    )
VAR t4 =
    SUMMARIZE (
        t3,
        [Origin1],
        [Destination1],
        [Destination2],
        "O&D_",
            IF (
                [Destination1] = Destination_,
                [Origin1] & "-" & [Destination1],
                [Origin1] & "-" & [Destination1] & "-" & [Destination2]
            )
    )
RETURN
    CONCATENATEX ( t4, [O&D_], "," & UNICHAR ( 10 ) & " " )

od.gif

BTW, archivo .pbix adjunto.

Saludos

Icey

Si este post ayuda,entonces considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

CNENFRNL
Community Champion
Community Champion

Hola, @MrNoob, es totalmente posible, pls probar el siguiente código,

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnH103UM8VHSAbGAJIgdqwMRdwkJh4uD2DBx/yAXuDiIDRYPCddFqITIwsSh6sHiMPVAe6DiENvB4rEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"O&D" = _t, Origin = _t, Destination = _t]),
    OD = Source[#"O&D"],
    #"Removed Columns" = Table.RemoveColumns(Source,{"O&D"}),
    #"Merged Queries" = Table.NestedJoin(#"Removed Columns", {"Destination"}, #"Removed Columns", {"Origin"}, "Source", JoinKind.LeftOuter),
    #"Renamed Columns" = Table.RenameColumns(#"Merged Queries",{{"Destination", "Exchange"}}),
    #"Expanded Source" = Table.ExpandTableColumn(#"Renamed Columns", "Source", {"Destination"}, {"Destination"}),
    #"Filtered Rows" = Table.SelectRows(#"Expanded Source", each ([Destination] <> null)),
    #"Added Custom" = Table.AddColumn(#"Filtered Rows", "Custom", each if List.Contains(OD, [Origin] & "-" & [Destination]) then [Origin] & "-" & [Destination] else false),
    #"Filtered Rows1" = Table.SelectRows(#"Added Custom", each ([Custom] <> false))
in
    #"Filtered Rows1"

el resultado final

Screenshot 2020-10-01 021418.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors