Forum Discussion

jalsing's avatar
jalsing
Frequent Visitor
8 years ago
Solved

Create new table/rows from extrapolated text in existing table

Hi,

I have a fairly complex (perhaps) issue I'm having some trouble figuring out. I have a datasource (from sharepoint) which has a number of columns, the 2 of interest here are "id" which is numeric and unique, and a "description" type field which is free form text input. Now the "description" field typically will mention a handful of city names. We'll use Houston, Austin, and Dallas for this example. I'd like to be able to use a map visual to filter a table visual based on if that city is mentioned in the description. So my idea is to have a "IdToDescription" table, with basically a row with each id, descrition combo. so incoming data like this:

id             description
----           --------------------------------------------------------
12 Major outage in Houston, as well as Austin this weekend.
13 Minor degradation in Dallas/Austin last night.

ends up like this

id               City
---- --------------- 12 Houston 12 Austin
13 Dallas
13 Austin

and from there I can use relationships to map the ID to city. The issue may be more complicated as some users may use "HN" etc but I can tackle that problem separately assuming there's a decent solution for the one presented.

 

Thanks

 

 

  • Hi jalsing,

     

    You may need a table to list all available cities.

     

    Then, create a calculated table with below DAX.

    New Table1 =
    SELECTCOLUMNS (
        FILTER (
            ADDCOLUMNS (
                CROSSJOIN ( Id_description, City ),
                "Isfind", NOT ( ISERROR ( FIND ( City[City], Id_description[description] ) ) )
            ),
            [Isfind] = TRUE ()
        ),
        "id", [id],
        "City", [City]
    )

     

    Best regards,

    Yuliana Gu

2 Replies

  • v-yulgu-msft's avatar
    v-yulgu-msft
    Microsoft Employee

    Hi jalsing,

     

    You may need a table to list all available cities.

     

    Then, create a calculated table with below DAX.

    New Table1 =
    SELECTCOLUMNS (
        FILTER (
            ADDCOLUMNS (
                CROSSJOIN ( Id_description, City ),
                "Isfind", NOT ( ISERROR ( FIND ( City[City], Id_description[description] ) ) )
            ),
            [Isfind] = TRUE ()
        ),
        "id", [id],
        "City", [City]
    )

     

    Best regards,

    Yuliana Gu

    • jalsing's avatar
      jalsing
      Frequent Visitor

      Thanks Yuliana, that appears to do exactly what I needed! (Although I ended up using SEARCH instead of FIND as it is case insensitive) Now I'm on to creating other tables to try to map eg "Texas" to all 3 cities.

       

      Thanks again!