Forum Discussion

maartjedutchy's avatar
maartjedutchy
Frequent Visitor
9 years ago
Solved

Lookup multiple text values in multiple columns

Dear Power BI community,

 

I'm struggling with the following. I have an export with a particular column which shows various labels which have been assigned to a post. These labels are all in one column separated by comma.  Here is an example of data. The column from export is how I load in the data in PowerBI, then with using queries, I seperate the column using delimiter comma and I get three new columns.

 

 

I need to create a stacked bar chart of 1 - labels vs 2 - labels. The advantage is dat all labels either start with 1 - or 2 - in front of it.  Any combination of 1- and 2- labels is possible,

 

The problem is that 1 - labels could be in either the 1,2 or 3 column, same goes for 2 -. This depends on what label the agent assigns first to a post. Then there is also the issue that agents could add two times a 1 - label AND a 2 - label, which normally isnt allowed. In that case I want to select the FIRST 1 - label icm with the corresponding 2 - label.

 

 

 

I've created an relationship with another datafile that contains all 1- and 2- labels, but it doesnt work cause I have more than one columns.. I know I need to probably use DAX but don't have much experience with it..

 

Any help would be greatly appreciated!

 

Kind regards,

 

Maartje

 

 

 

  • Anonymous's avatar
    Anonymous
    9 years ago

    Hi maartjedutchy,

     

    >>Yeah I tried unpivot, but I have over 46 columns in this data source and 200.000 rows of data (therefore its difficult to share my PBIX).

    I think you can spilt part of your data an share us as a sample to test, it will be help to analysis.

     

    In addition, I think you not need to unpivot your original table, you can try to use search/find functions to lookup the related values and combine if statement to check with different conditions.

     

    Regards,

    Xiaoxin Sheng

4 Replies

  • vanessafvg's avatar
    vanessafvg
    Community Champion

    maartjedutchy hi are able to share your pbix?  

     

    i think what you actually need to do is unpivot in power query all 3 columns to create a row for each one, that way you can easily remove duplicates and have an instance of each label and category.