Forum Discussion

abhishekpati86's avatar
abhishekpati86
Helper III
9 years ago
Solved

Getting the value from the excel sheet for 2 different columns and rendering it in power BI

Here is the requirement. I have the below matrix from a dataset containing some text values in End User Trade Name.

 

 

The 3rd column contains a score and it is set to 1 for a selected group of texts that is coming from another excel file.

 

 

I have a table named the same in my Report and when the text matches it to the one in the list, the score is set to 1 for that entry. The excel is for the purpose that anyone can enter the values and just have to do a refresh in the Power BI to update the score for those set of values.

 

Below is the code that is doing it - 

 

ScoreTrade = IF(
SUMX(Keyword_Trade_Name,
FIND(
UPPER(Keyword_Trade_Name[Trade_Name]),
UPPER(Table_Test[End User Trade Name])
,,0
)
) > 0,
1,
0
)

 

I am hardcoding the value to be 1(in bold above) in this case here but I don't want it to do that way. I want it to be taken from an excel file and the value can be set by the user (maybe 2 , 3 and can be different for individual fields).See the below screenshot for details 

 

 

Can you suggest a way to do that so that I don't have to hardcode it but maybe use the same excel sheet to add another column with the value ?

  • Hi sridevi,

     

    Because there doesn’t exist any relationshipbetween two tables, to return the value from Keyword_Trade_Name table, you need to join these two tables:

    crossjoinTbl = ADDCOLUMNS(CROSSJOIN(Keyword_Trade_Name,Table_Test),"match value",IF(FIND(Keyword_Trade_Name[Trade_Name],Table_Test[End User Trade Name],,0)>0,Keyword_Trade_Name[value],0))

     

    Select columns from this new table to add to table visualization.

     

    If you have any question, please feel free to ask.

     

    Best regards,
    Yuliana Gu

7 Replies

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

    Hi sridevi,

     

    Because there doesn’t exist any relationshipbetween two tables, to return the value from Keyword_Trade_Name table, you need to join these two tables:

    crossjoinTbl = ADDCOLUMNS(CROSSJOIN(Keyword_Trade_Name,Table_Test),"match value",IF(FIND(Keyword_Trade_Name[Trade_Name],Table_Test[End User Trade Name],,0)>0,Keyword_Trade_Name[value],0))

     

    Select columns from this new table to add to table visualization.

     

    If you have any question, please feel free to ask.

     

    Best regards,
    Yuliana Gu

    • Anonymous's avatar
      Anonymous
      Not applicable

      abhishekpati86

       

      Try the following

       

      1. Add an Index column to your table containing KeyWord_Trade_Name against each Name starting with 1 and on.

          So yourKeyWord_Trade_Name will have columns Name,Score,Index

      2. Create a column in Table_test as follows

         

                                        MatchedIndex=
                                                             SUMX(SearchNames,
                                                                            If (FIND(UPPER(KeyWord_Trade_Name [Name]),
                                                                                              UPPER(Table_test [EndUserName]),,0
                                                                                               ) >0,(KeyWord_Trade_Name [Index])-2999997,9999999 )


                                                                             )

      4. This would return the values as 1,2,3.... depending on the match or else 999999.

      5. In the Mange relationship create relationship between KeyWord_Trade_Name[Index] and Table_test[MatchedINdex]

      6. Create a column in Table_test 

            NewScoreTrade = Related(KeyWord_Trade_Name [Score])

       

      7. Now plot the reports with NewScoreTrade , this will be dynamic then.

       

      8.  The only thing I am unable to explain why in the If conditions one needs to put the odd numbers like 2999997. This number to subtract varies based on the else value 9999999.  If you change the else value you have to change the 2999997 also accordingly.

       

      Try it out if it solves your issue please accept this as a solution and also give KUDOS.

       

      Cheers

       

      CheenuSing

       

       

                       

       

      • abhishekpati86's avatar
        abhishekpati86
        Helper III

         

        Anonymous - Please see above the MatchedIndex, I have also created the manage relationship as below. Still it seems to not work. Can you suggest what is wrong over here.