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
gluizqueiroz
Resolver I
Resolver I

How to create a slice filter with a measure.

I have a measure that returns me 2 words:
"Sold" or "Unsold"

I wanna create a slicer like the following and when user click on button, the slicer filter a visual table showing only the products selected (The products sold or the unsold or both, if user select both options, like a normal slicer)

image.png


But, like as you know, I can't put a mesure on a slicer, it needs to be a real column. 
How can I create this slicer?
I search on internet and find something about create a exclusive table with 1 column and 2 lines (Sold and Unsold), put this column on a slicer and create a measure to link them, but I don't know if this solution works for my problem, or it works but I don't know how to implement them.

Thanks

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @gluizqueiroz ,

 

As you refer you need to create a table with two lines:

 

Sold

Unsold

 

Then create a measure similar to this:

FIlter data =
IF (
    COUNT ( 'Sold/Unsold'[Cat] ) > 1;
    1;
    IF (
        MAX ( 'Sold/Unsold'[Cat] ) = "Sold";
        COUNTX (
            FILTER (
                SUMMARIZE ( Sales; Sales[Product]; "Sold"; [Sold/Unsold] );
                [Sold] = "Sold"
            );
            [Sold]
        );
        COUNTX (
            FILTER (
                SUMMARIZE ( Sales; Sales[Product]; "Unsold"; [Sold/Unsold] );
                [Unsold] = "Unsold"
            );
            [Unsold]
        )
    )
)

Be aware that this measure is based on way to count the rows of products that have sold or unsold, but the resul will be simply 1 per row.

 

I then used this to filter the table visual to get the final result.

 

Check PBIX file attach.

 

Regards,

MFelix


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

1 REPLY 1
MFelix
Super User
Super User

Hi @gluizqueiroz ,

 

As you refer you need to create a table with two lines:

 

Sold

Unsold

 

Then create a measure similar to this:

FIlter data =
IF (
    COUNT ( 'Sold/Unsold'[Cat] ) > 1;
    1;
    IF (
        MAX ( 'Sold/Unsold'[Cat] ) = "Sold";
        COUNTX (
            FILTER (
                SUMMARIZE ( Sales; Sales[Product]; "Sold"; [Sold/Unsold] );
                [Sold] = "Sold"
            );
            [Sold]
        );
        COUNTX (
            FILTER (
                SUMMARIZE ( Sales; Sales[Product]; "Unsold"; [Sold/Unsold] );
                [Unsold] = "Unsold"
            );
            [Unsold]
        )
    )
)

Be aware that this measure is based on way to count the rows of products that have sold or unsold, but the resul will be simply 1 per row.

 

I then used this to filter the table visual to get the final result.

 

Check PBIX file attach.

 

Regards,

MFelix


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



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.