Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
GFRO
Frequent Visitor

Search Value on Multiple Columns and return all associated

Hi all,

I have a table populated with names in different columns. Each row represents salesperson names who worked together on a specific date.

 

My expected result is a list of names who worked together with the value selected in the slicer but excluding this same value selected in the slicer.

In the example below, we see that 'Sarah' can be in Salesperson 1, Salesperson 2 or Salesperson 3. Also, Sarah has never worked with Caroline, that's why Caroline is not showing in the expected result.

 

Salesperson 1Salesperson 2Salesperson 3
SarahMike 
CarlosJennifer 
NicoleSarah 
JohnJenniferCaroline
CarolineMike 
NicoleCarlosSarah
SarahMarinaMike

 

EXPECTED result when filtering 'Sarah' on slicer:

Salesperson
Mike
Nicole
Carlos
Marina

 

I've tried so many things but couldn't get a satisfactory result.

Any help is much appreciated.

6 REPLIES 6
parry2k
Super User
Super User

@GFRO just to let you know 2000 rows are very small, even 2 million, so if you want a scalable solution, unpivot is the way to go. Rest choice is yours.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

JorgePBI
Frequent Visitor

Create a new calculated table in Power BI that combines all the salesperson names into a single column. You can use the UNION function to achieve this:

AllSalespersons = UNION(VALUES(Sales[Salesperson 1]), VALUES(Sales[Salesperson 2]), VALUES(Sales[Salesperson 3]))

 Create a DAX measure to calculate the selected salesperson based on the slicer selection. Let's call this measure "SelectedSalesperson":

SelectedSalesperson = SELECTEDVALUE(AllSalespersons, "")

Create another calculated table to filter out the selected salesperson from the "AllSalespersons" table:

OtherSalespersons = FILTER(AllSalespersons, [AllSalespersons] <> [SelectedSalesperson])

Finally, use a table visual and display the "OtherSalespersons" calculated table. This table will show the list of names who worked with the selected salesperson but exclude the selected salesperson itself.
When you use the slicer to select a salesperson, the table visual will dynamically update to display the names of other salespersons who worked with the selected person, excluding the selected person.

Remember to set up the slicer to use the "SelectedSalesperson" measure for its value selection. This way, the slicer controls the filtering based on the selected salesperson.

GFRO
Frequent Visitor

Hi Jorge,

 

I appreciate your help.

However, I couldn't create the metric SelectedSalesperson once Allsalesperson we created in the first place it's a measure. SELECTEDVALUE has a <column> in its syntax. The same applies to the OtherSalesperson measure where FILTER syntax needs a <table>.

 

 Do you see any alternative to overcome that?

JorgePBI
Frequent Visitor

FYI - AllSalespersons, The first dax is for creating the table that your are going to need, is not a dax for a measure, is the dax you use when you create a new table.

JorgePBI_0-1697728980493.png

then you paste the dax

JorgePBI_0-1697730892287.png

 

parry2k
Super User
Super User

@GFRO the best approach is to unpivot your data, salesperson 1, 2, 3 on rows and you can always visualize using matrix visual to show salesperson 1, 2, 3 on columns, but it will not require any complex calculation to find Sarah. Then you can easily search for the salesperson and it will show wherever it exists.

 

It is important to shape the data in a way that removes the complexity. I hope it helps.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

GFRO
Frequent Visitor

I appreciate your effort, @parry2k. However, the original table has over 2,000 rows.

It'd be insane to visualize that in the report view.

 

Do you have any other idea?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.