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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
sanjay009
Helper III
Helper III

slicer with yes and No

i have the data as below

 

id    type

1     fruit

2     vegetable

3     fruit

4     fruit

5     vegetable

 

i am looking for slicer filter with display yes and no option. 

Yes - all records

No - exclude vegetables.

 

Can anyone help how can i do this.

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @sanjay009 

You can create a measure and add it to visual level filter as below:

Capture10.JPGCapture11.JPG

 

if show = IF(SELECTEDVALUE('slicer table'[slicer])="yes",1,IF(MAX('Table'[ type])<>"vegetable",1))

 

Or create measures and add it the column chart

Measure =
SWITCH (
    MAX ( 'new table'[slicer] ),
    "no", CALCULATE (
        DISTINCTCOUNT ( 'Table'[id] ),
        FILTER (
            'Table',
            'Table'[ type] <> "vegetable"
        )
    ),
    "yes", DISTINCTCOUNT ( 'Table'[id] )
)

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

9 REPLIES 9

how we can give the multiple catgories in measure like vegetables,fruits

domain

yopmail.com

yahoo.com

gmail.com

agency.com

 

i am looking for slicer filter with display yes and no option. 

Yes - all records

No - exclude yopmail.com and yahoo.com.

 

can someone pls help me. how to do this

v-juanli-msft
Community Support
Community Support

Hi @sanjay009 

You can create a measure and add it to visual level filter as below:

Capture10.JPGCapture11.JPG

 

if show = IF(SELECTEDVALUE('slicer table'[slicer])="yes",1,IF(MAX('Table'[ type])<>"vegetable",1))

 

Or create measures and add it the column chart

Measure =
SWITCH (
    MAX ( 'new table'[slicer] ),
    "no", CALCULATE (
        DISTINCTCOUNT ( 'Table'[id] ),
        FILTER (
            'Table',
            'Table'[ type] <> "vegetable"
        )
    ),
    "yes", DISTINCTCOUNT ( 'Table'[id] )
)

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

AlB
Super User
Super User

Hi @sanjay009 

 

1. Create a one-column table Slicer[Selection] with two rows: "Yes" and "No"

2. Place Table1[id] and Table1[type] in a table visual as you are already showing

3. Place Slicer[Selection] in a slicer visual

4. Create this measure

 

ShowMeasure =
IF (
    "Yes" IN DISTINCT ( Slicer[Selection] ),
    1,
    IF ( SELECTEDVALUE ( Table1[type] ) = "Vegetable", 0, 1 )
)

 

5. Place the measure in the visual filters for the table visual and choose to show if result is 1

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

should I create measuse for dataset Data or Table.

mahoneypat
Employee
Employee

Assuming you have a disconnected table called Slicer (e.g., use Enter Data to make a table with Yes and No, and have no relationships to other tables), you can use a measure like this to get your desired result:

 

SlicerCount = if(selectedvalue(Slicer[Decision]) = "Yes", countrows(Data), Calculate(countrows(Data), Data[Type]="Fruit"))

 

This also assumed your table is called "Data" and the Slicer column is called "Decision".

 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Here are the steps i followed.

 

1. Created a table  with Slicer and column Selection with roes Yes and No.

2. Created a measure under table SlicerCount with the formula you provided.

3.added a Visual Slicer for selection.

4. when i click Yes and No . row counts are same.

 

Please let me know where i missed.

@sanjay009 

Step 5

5. Place the measure in the visual filters for the table visual and choose to show if result is 1

https://www.sqlbi.com/articles/applying-a-measure-filter-in-power-bi/

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

Thanks for your patienace.

 

1.jpg

 

2.JPG

 

3.JPG

4.JPG

 

expecting like yes and no. i am able to see only graph. and able to choose to show if result is 1 (where should i add this)

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors
Top Kudoed Authors