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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
datadelta
Helper III
Helper III

Still issues with making a slicer an "and" rather than an "or"

I'm trying to return only those that have multiple selected items.  It will show those but it also brings back any that have one or the other.  Any ideas?  Here's my formula

 

All categories =
var numofselectedcategories=COUNTROWS(VALUES('ProductList'[product]))  
VAR Ratings=
SUMMARIZE(ProductList, ProductList[Custid], 'ProductList'[product])
var multipair=
GROUPBY(Ratings,
ProductList[product],"@rate",SUMX(CURRENTGROUP(),1))
var SameImpair=
FILTER(multiimpair,[@rate]=numofselectedproduct)
 RETURN
 COUNTROWS(product)
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @datadelta 

Thanks for your quick reply, you can try the folllwing measure.

MEASURE =
VAR numofselectedcategories =
    COUNTROWS ( ALLSELECTED ( 'Impairment'[Impairments] ) )
VAR Ratings =
    SUMMARIZE (
        ALLSELECTED ( 'Impairment' ),
        'Impairment'[CaseId],
        [Submitted To],
        "Counts_impairments", DISTINCTCOUNT ( Impairment[Impairments] )
    )
VAR _Counts_submittedto =
    CALCULATE (
        DISTINCTCOUNT ( Impairment[Submitted To] ),
        ALLSELECTED ( Impairment ),
        Impairment[CaseId] IN VALUES ( Impairment[CaseId] )
    )
VAR _add =
    ADDCOLUMNS (
        Ratings,
        "Flag", IF ( [Counts_impairments] = numofselectedcategories, 1, 0 )
    )
VAR _sumflag =
    SUMX ( FILTER ( _add, [CaseId] IN VALUES ( Impairment[CaseId] ) ), [Flag] )
RETURN
    IF ( _sumflag = _Counts_submittedto, 1, 0 )

Then put the measure to the visual filter.

vxinruzhumsft_0-1721960987939.png

Output

vxinruzhumsft_1-1721961147226.png

Best Regards!

Yolo Zhu

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

10 REPLIES 10
Anonymous
Not applicable

Hi @datadelta 

You can try the following.

All categories =
VAR numofselectedcategories =
    COUNTROWS ( VALUES ( 'ProductList'[product] ) )
VAR Ratings =
    SUMMARIZE (
        ALLSELECTED ( 'ProductList' ),
        'ProductList'[Custid],
        "Counts", COUNTROWS ( 'ProductList'[product] )
    )
VAR c =
    ADDCOLUMNS ( Ratings, "Flag", IF ( [Counts] = numofselectedcategories, 1, 0 ) )
RETURN
    SUMX ( c, [Flag] )

 

Best Regards!

Yolo Zhu

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

Thank you.  Unfortunately this still brings back all results for the items, not just the ones who have the choices made in the selector.  This is also doing a count and I'm trying to use the slicer to only return those results that have either the single item selected or the multiple selections.  Thanks for the possible solution though!

Anonymous
Not applicable

Hi @datadelta 

Thanks for your quick reply, can you provide some sample data and the output you want so that can provide more suggestion for you.

 

Best Regards!

Yolo Zhu

I cannot share the data as it is very sensitive information but here's the formula using my data points.  The CaseID is the delta that all information is tied to.  The "impairment" is the item being used in the slicer to choose multiples.  I'm trying to get the "and" function to return the CaseID and "rateclass" associated with any CaseID's that have those impairments.  

 

I hope that helps and I appreciate the assistance.

All categories =
var numofselectedcategories=COUNTROWS(VALUES(Impairment[Impairment]))  
VAR Ratings=
SUMMARIZE(Impairment, Impairment[Impairment], Impairment[CaseId])
var multipair=
GROUPBY(Impairment,
Impairment[CaseId],"@rate",SUMX(CURRENTGROUP(),1))
var SameImpair=
FILTER(multipair,[@rate]=numofselectedcategories)
 RETURN
 (System[Impairment])
Anonymous
Not applicable

Hi @datadelta 

Thanks for your quick reply, based on your code, did you create it as a measure instead of calculated column, and you may be misleading me about what I mean, you don't need your real data, can you create some sample data based on your needs, because based on formulas alone can't guarantee that the proposed solution will meet your expectations.

 

Best Regards!

Yolo Zhu

I did have it as a measure so I updated to calculated column.  No luck.

Here's the redacted data.  I put the items that have results associated with both "impairments" Thanks for your help!

CaseIdSubmitted ToImpairmentsRateClass
59825Company1Impairment1OfferY
59825Company2Impairment1OfferY
59825Company3Impairment1OfferY
59825Company4Impairment1OfferY
59825Company5Impairment1OfferY
59825Company6Impairment1OfferY
60054Company 7Impairment1OfferY
60054Company 7Impairment2OfferN
60289Company8Impairment2OfferN
60289Company9Impairment2OfferN
60289Company2Impairment2OfferY
60289Company2Impairment1OfferY
60293Company5Impairment1OfferN
60293Company5Impairment2OfferN
Anonymous
Not applicable

Hi @datadelta 

Thanks for your quick reply, you can try the folllwing measure.

MEASURE =
VAR numofselectedcategories =
    COUNTROWS ( ALLSELECTED ( 'Impairment'[Impairments] ) )
VAR Ratings =
    SUMMARIZE (
        ALLSELECTED ( 'Impairment' ),
        'Impairment'[CaseId],
        [Submitted To],
        "Counts_impairments", DISTINCTCOUNT ( Impairment[Impairments] )
    )
VAR _Counts_submittedto =
    CALCULATE (
        DISTINCTCOUNT ( Impairment[Submitted To] ),
        ALLSELECTED ( Impairment ),
        Impairment[CaseId] IN VALUES ( Impairment[CaseId] )
    )
VAR _add =
    ADDCOLUMNS (
        Ratings,
        "Flag", IF ( [Counts_impairments] = numofselectedcategories, 1, 0 )
    )
VAR _sumflag =
    SUMX ( FILTER ( _add, [CaseId] IN VALUES ( Impairment[CaseId] ) ), [Flag] )
RETURN
    IF ( _sumflag = _Counts_submittedto, 1, 0 )

Then put the measure to the visual filter.

vxinruzhumsft_0-1721960987939.png

Output

vxinruzhumsft_1-1721961147226.png

Best Regards!

Yolo Zhu

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

This worked!  I cannot thank you enough for sticking with me on this.  I've been trying to solve this for several days and your help made it possible!

Thank you!

Shravan133
Super User
Super User

Hi,

 

try this:

All categories =
VAR NumOfSelectedCategories = COUNTROWS(VALUES('ProductList'[product]))
VAR CustProducts =
SUMMARIZE(
ProductList,
ProductList[Custid],
"NumProducts", COUNTROWS(VALUES(ProductList[product]))
)
VAR FilteredCustProducts =
FILTER(
CustProducts,
[NumProducts] = NumOfSelectedCategories
)
RETURN
COUNTROWS(FilteredCustProducts)

 

 

Thank you.  Unfortunately this still brings back all results for the items, not just the ones who have the choices made in the selector.  This is also doing a count and I'm trying to use the slicer to only return those results that have either the single item selected or the multiple selections.  Thanks for the possible solution though!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.