Forum Discussion

PowerBIGpig's avatar
PowerBIGpig
Frequent Visitor
6 years ago

Cross reference another table to retrieve text value

Hello!

I am trying to reference a table that has a list of activities to a table that has a list of purchases that "should" have the activities as the first characters of the description. E.g.

Table of Activities

ActivitiesWBS
ABC.1.1ABC
ABC.2.1ABC
DEF.1.1DEF

Table of purchases

WBSDescriptionAmt
ABCABC.1.1 Stuff$20
DEFDEF.1.1. things$33
ABCABC.2.1 More stuff$44
ABCFreight$10

 

Table to look like

WBSDescriptionAmtActivity
ABCABC.1.1 Stuff$20ABC.1.1
DEFDEF.1.1. things$33DEF.1.1
ABCABC.2.1 More stuff$44ABC.2.1
ABCFreight$10Unknown1

Is there a way to do this in Power BI Desktop?

Thanks!

7 Replies

  • PowerBIGpig ,

    Try a new column like

    New column = Maxx(filter(Table1,Table1[WBS]= Table2[WBS] && search(Table2[Activities],table1[Description],,0)>0),Table1[Activities])

    • PowerBIGpig's avatar
      PowerBIGpig
      Frequent Visitor

      Thanks for your reply !

      I'm getting an error which is higlighting "search". It says "Token Literal Expected"

       
      • v-lid-msft's avatar
        v-lid-msft
        Community Support

        Hi PowerBIGpig ,

         

        We can use the following measure to meet your requirement:

         

        Activity = 
        COALESCE (
            CALCULATE (
                MAX ( 'Activities'[Activities] ),
                FILTER (
                    'Activities',
                    'Activities'[WBS] = 'purchases'[WBS]
                        && CONTAINSSTRING ( 'purchases'[Description], 'Activities'[Activities] )
                )
            ),
            "Unknown1"
        )

         

         


        By the way, PBIX file as attached.


        Best regards,

         

  • v-lid-msft's avatar
    v-lid-msft
    Community Support

    Hi PowerBIGpig ,

     

    How about the result after you follow the suggestions mentioned in my original post?Could you please provide more details about it If it doesn't meet your requirement?


    Best regards,