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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.