Forum Discussion

Ormesome's avatar
Ormesome
Helper II
8 years ago
Solved

Map visualisation with multiple datasets?

I've got 2 datasets to present. The first is a list of offices and their addresses. The second is a list of postcodes covered by each office.   Ideally I'll show a map with a pin/bubble indicating ...
  • Anonymous's avatar
    Anonymous
    8 years ago

    HI Ormesome,

     

    Based on test, current power bi not support auto determine the relationship mapping on Multi-records to Multi-records.

     

    On my opinion, I'd like to suggest merge and append these columns to one table, then use it as the source of map visual.

     

    Steps:
    1. Duplicate 'Catchments' table.
    2. Add custom column postcode to lookup value from 'CatchmentPostcodes' table.

    =Function.Invoke((id as any) => Table.SelectRows(CatchmentPostcodes,each [CatchmentID]= id),{[CatchmentID]})[Postcode]

    3. Add custom column Address to lookup values from 'CatchmentOffices' table.

    =Function.Invoke((id as any) => Table.SelectRows(CatchmentOffices,each [CatchmentID]= id),{[CatchmentID]})[Address]

    4. Expand above columns to new row.

     

    Result:

     

    Full query:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfLMy0stUiguTSotSipWitWJVjICivrlF5VkpBbloUgYAyWC80sxJUyAEq6JxSXo4qZA8fBUNPFYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [CatchmentID = _t, Description = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"CatchmentID", Int64.Type}, {"Description", type text}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Postcode", each Function.Invoke((id as any) => Table.SelectRows(CatchmentPostcodes,each [CatchmentID]= id),{[CatchmentID]})[Postcode]),
        #"Added Custom1" = Table.AddColumn(#"Added Custom", "Address", each Function.Invoke((id as any) => Table.SelectRows(CatchmentOffices,each [CatchmentID]= id),{[CatchmentID]})[Address]),
        #"Expanded Postcode" = Table.ExpandListColumn(#"Added Custom1", "Postcode"),
        #"Expanded Address" = Table.ExpandListColumn(#"Expanded Postcode", "Address")
    in
        #"Expanded Address"

     

    Regards,

    Xiaoxin Sheng