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
DeBIe
Post Partisan
Post Partisan

How to filter by two columns?

Hey all,

 

I'm not sure how to built the following customer requirement.

 

In my report I have companies and company codes. Every month our customer will send us an Excel-file with company codes and two extra columns with sales persons. They would like to have one filter for the sales guys that are responsible for the company. I will show an example below:

Excel file deliverd by customer: 

CompanyIDCompanyNameSalesPerson1SalesPerson2
1AWallmartBobHelen
1BBilly'sHelenBob
1CMindy'sJohnBob
1DBurgerKingCarlCindy

 

PowerBI Dataset

CompanyIDCompanyName
1AWallmart
1BBilly's
1CMindy's
1DBurgerKing

 

The end result scenario should be the following. There has to be one filter called "SalesPerson". If the end-user should select "Bob" in this filter, then the following data must show:

CompanyIDCompanyName
1AWallmart
1BBilly's
1CMindy's

 

Thank you for your time. 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You need to tweak the model. Firstly, get all the salespeople into one column by opening power query and selecting the company ID and company name columns from the excel file then unpivot other columns. rename the value column to salesperson and delete the attribute column as you don't need it.

You then need to create a table which contains the distinct salespeople. You can either do this in power query or in DAX.

You can now use the table from excel as a bridge between the companies and the salespeople, and link it your fact table.

johnt75_0-1676973903767.png

See the attached PBIX for a sample.

You might also find https://www.sqlbi.com/articles/different-options-to-model-many-to-many-relationships-in-power-bi-and... from SQLBI useful.

View solution in original post

7 REPLIES 7
Ahmedx
Super User
Super User

look at this option
https://dropmefiles.com/ObgBn
Screen Capture #340.pngScreen Capture #341.pngScreen Capture #342.png

Hi @Ahmedx 

 

Thank you for your time and suggested solution. I've implemented @johnt75 solution and that works fine already for me.

johnt75
Super User
Super User

You need to tweak the model. Firstly, get all the salespeople into one column by opening power query and selecting the company ID and company name columns from the excel file then unpivot other columns. rename the value column to salesperson and delete the attribute column as you don't need it.

You then need to create a table which contains the distinct salespeople. You can either do this in power query or in DAX.

You can now use the table from excel as a bridge between the companies and the salespeople, and link it your fact table.

johnt75_0-1676973903767.png

See the attached PBIX for a sample.

You might also find https://www.sqlbi.com/articles/different-options-to-model-many-to-many-relationships-in-power-bi-and... from SQLBI useful.

Hi @johnt75 

 

Thank you for your time and suggest solution.

 

I've tried your solution. However, I need it to work without the measure that you've added. I need to be able to select a sales person and that should then also filter down the companies. This does not work when I remove the measure. 

I can think of a couple of options. You could either use the Company Name column from the bridge table, or you could make the relationship between the bridge table and the PowerBI table bidirectional.

If you are only interested in the company name then I would probably choose the first option, but if there are other attributes about a company that you need filter then you will need to use the bidirectional relationship.

Ahmedx
Super User
Super User

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
https://dropmefiles.com/8v7fK
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

Screen Capture #330.pngScreen Capture #331.pngScreen Capture #332.pngScreen Capture #333.pngScreen Capture #334.png

Hey @Ahmedx  thank you for your suggested solution.

 

I need to be able to apply the filter to several pages, instead of one or multiple visuals. The difficulty I see here is that I need to add the measure on visual level? 

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.