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
Ouhla
Frequent Visitor

Use segment to filter across several columns of the same table

Hi everyone,


I have a table with several columns, but 3 are important, let's name them "A", "B" and "C". I have several metrics related to these columns in this table but what matters to me is that "A", "B" and "C" all contain either yes or no, I would like to include on my report a segment that allows filtering by Yes or No for these 3 columns individually, how do I do this? Currently, if I drop these 3 columns into a segment, I only have Yes or No as a drop-down list.

In short, I'd like to have "A", "B", "C" in the same segment and be able to drop down "Yes" or "No" as a filter for each.

Thanks a lot!

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

You will have to use the "Unpivot Other Columns" feature in Power Query to tranform those 3 columns into a single one.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-heq-msft
Community Support
Community Support

Hi @Ouhla ,
Thanks to @amitchandak  for the solution.
Based on your description, the functionality you are trying to achieve is similar to what Field Parameter is trying to demonstrate.
Here some steps that I want to share, you can check them if they suitable for your requirement.
Here is my test data:

vheqmsft_0-1713753886671.png

Create filed parameter

vheqmsft_1-1713753943358.png

If you only use the filed parameter, you can manipulate the visual object to control which fields are displayed.

vheqmsft_2-1713754220905.png

If you want to implement a dropdown box, first you need to create a new column Y/N in the Parameter table

vheqmsft_3-1713754319659.png

Then put the new column into the slicer you just created.

vheqmsft_4-1713754387805.png
Create a measure

Measure = SELECTEDVALUE(Parameter[Y/N])

Apply to the table filter

vheqmsft_5-1713754444900.png

 


Final output

vheqmsft_6-1713754465461.png

vheqmsft_7-1713754472736.png

Best regards,

Albert He

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 



 

 

 

amitchandak
Super User
Super User

@Ouhla , Not very clear. But create a table with a one column having two values "Yes" and "No"

Now use that in slicer

 

now you can have measures like

 

countrows(filter( Table, Table[A] = selectedvalue(YN[YN])  && Table[B] = selectedvalue(YN[YN])  && Table[C] = selectedvalue(YN[YN]) ) )

 

You can use OR in place of and

Hello, sorry if my question was unclear. To sum up, I have a table who look like this :

 

Test_Table = 
SELECTCOLUMNS(
    ADDCOLUMNS(
        GENERATESERIES(1, 5),
        "A", IF(RAND() > 0.5, "Yes", "No"),
        "B", IF(RAND() > 0.5, "Yes", "No"),
        "C", IF(RAND() > 0.5, "Yes", "No"),
        "Metrics1", ROUND(RAND() * 100, 0),
        "Metrics2", ROUND(RAND() * 100, 0)),
    "A", [A],
    "B", [B],
    "C", [C],
    "Metrics1", [Metrics1],
    "Metrics2", [Metrics2]
)

 

A

B

C

Metrics1

Metrics2

Yes

YesYes655
NoNoYes274
NoYesYes655
NoNoYes6478
YesYesYes428


My goal is to create a filter so that we can filter on a visual of this table the rows that are Yes or No for columns "A", "B", "C".

I didn't know the field parameter function, so I created a filter parameter table with the 3 columns A, B, C with this code : 

 

Parameter = {
    ("A", NAMEOF('Test_Table'[A]), 0, "Yes"),
    ("B", NAMEOF('Test_Table'[B]), 1, "Yes"),
    ("C", NAMEOF('Test_Table'[C]), 2, "Yes"),
    ("A", NAMEOF('Test_Table'[A]), 0, "No"),
    ("B", NAMEOF('Test_Table'[B]), 1, "No"),
    ("C", NAMEOF('Test_Table'[C]), 2, "No")
    }

 

I'm super happy because with this, the filter look the way I want, but now I'm struggling to connect that with my Test_Table, even with your code, do I need to create a measure like this ?

 

Measure = FILTER('Test_Table', 'Test_Table'[A] = SELECTEDVALUE('Parameter'[Value4]) || 'Test_Table'[B] = SELECTEDVALUE('Parameter'[Value4]) ||  'Test_Table'[C] = SELECTEDVALUE('Parameter'[Value4]) = SELECTEDVALUE('Paramètre'[Value4]))

 


?
Sorry again if my question wasn't clear from the start, and sorry I didn't provide a code to enable reproduction, thanks for the answers which actually helped me move forward I'm super happy about it !

 

 

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.