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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Luden76
Frequent Visitor

One slicer to control two columns at the same time

Hello Guys,

I'm quite new to power bi. I have just one lookup table and multiple fact tables and their relationships are all one to many. I want to create a slicer using category column in the lookup table to filter one specific table based on either category or old category columns. Also this slicer is filtering other visuals as a normal filter.

Luden76_0-1644964693528.png

 

For example if you select golf, this one specific table is going to show category = golf or old category = golf.

 

Luden76_2-1644964876680.png

So I'm thinking that I can create a measure counting rows based on the criteria above and get 1 if true for each row and filter that measure = 1

 

I created this measure:

PickThis =
var _selectedCategory = SELECTEDVALUE(MA_Lookup[Category Desc])
return
CALCULATE(COUNTROWS(MA_Up_Downgrade) , FILTER(ALL(MA_Up_Downgrade),MA_Up_Downgrade[Category Desc] = _selectedCategory || MA_Up_Downgrade[Old Category] = _selectedCategory ))
 
So basically if either column is golf, then count each row as 1. Then later I can filter this measure to 1 to achieve my goal. However, if I select golf, it's giving me total numbers for each row instead of 1 if the condition is true. Also if nothing is selected, it's showing blank, but I need the table to show all.
Luden76_3-1644965496963.png
Luden76_0-1645027948438.png

 

P.S. I have tried creating a diconnected slicer table including all categories and it worked, but in the ideal situation, I only need one slicer only from lookup table instead of two.

Here is the sample file.

https://drive.google.com/file/d/15gVjklMerU-AgayrmMqezptByh3tQq51/view?usp=sharing 

3 REPLIES 3
DataInsights
Super User
Super User

@Luden76,

 

Try this solution. You can put the measure in a visual filter.

 

https://community.powerbi.com/t5/Desktop/Once-Slicer-for-multiple-columns/m-p/430979#M198545 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@DataInsights 

Hi, thanks for your reply. I took a look at the solution and seems like you have to created a disconnected slicer table with no relationships to any table. So it's  impossible to just use the one column from the lookup table as a slicer to control two columns in the fact table while still have a one to many relationship between them?

@Luden76,

 

Here's an alternative that allows you to keep the slicer connected to the data model. Create a calculated table that is a summary of the fact table (summarize by the columns displayed in the visual):

 

SummaryTable = SUMMARIZE ( MA_Up_Downgrade, MA_Up_Downgrade[Category Desc], MA_Up_Downgrade[Old Category], MA_Up_Downgrade[Type] )

 

This table has no relationships. Add columns from this table to the visual. Create measure:

 

Filter Visual = 
VAR vCategorySelected =
    VALUES ( MA_Lookup[Category Desc] )
VAR vResult =
    CALCULATE (
        COUNTROWS ( SummaryTable ),
        FILTER (
            SummaryTable,
            SummaryTable[Category Desc]
                IN vCategorySelected
                || SummaryTable[Old Category] IN vCategorySelected
        )
    )
RETURN
    vResult

 

Filter the visual where this measure = 1.

 

DataInsights_0-1645719482372.png

-------------------------------------------------------------

DataInsights_1-1645719504028.png

The link below is to a similar post. The difference is that no additional fact table columns are in the visual. Since a slicer often controls multiple visuals, it's preferable to keep the slicer connected to the data model and create a disconnected summary table for special cases.

 

https://community.powerbi.com/t5/Desktop/Filter-Table-by-Column-Values-Associated-with-Selected-Slic... 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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