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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Advocate I
Advocate I

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?

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors