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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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

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
v-xinruzhu-msft
Community Support
Community Support

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!

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])

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

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
Solution Sage
Solution Sage

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.