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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
tmears
Helper III
Helper III

Multiple Slicer with AND Logic

I wonder if anyone can help, i have been going around in circles with this one for days.  
I will try to explain as best as i can
this is an example data table i have

tmears_0-1705328214881.png

 


i want to build a slicer on the sales person and the stage, however if i select multiple stages on the stage slicer i want to only return data when the sales person is the only sales person on the selected stages on the order.
For example if i selected sales person 10 on the sales person slicer and stages 1 and 2 on the stage slicer it would return 1 as he was the sales person in both stage 1 and 2 on sales order 01F0AFDD-DAD8-EB11-BACB-0022484232D1 (Highlighted)  However if i selected stages 1, 2 and 3 on the stage slicer it would return 0 as although he was the sales person on stage 1 and 2 he was not the sales person on stage 3

I hope i have explain that well enough

i have the following but it does not work as intended:

OrdersDeliveredBysalespersonAndStage v2 =
CALCULATE(
    DISTINCTCOUNT('salesorder'[Order]),
    FILTER(
        'salesorder',
        NOT ISBLANK('salesorder '[Sales Person]) &&
        'salesorder '[Stage] IN VALUES('salesorder '[Stage])
    ),
    ALLEXCEPT('salesorder ''salesorder '[Stage]),
    'salesorder (2)'[sales person] = SELECTEDVALUE('salesorder'[sales person])
)

any help would be really appreciated as driving me crazy
1 ACCEPTED SOLUTION

@tmears,

 

Try this:

 

1. Create calculated table (no relationships):

 

SalesPersonSlicer = DISTINCT ( salesorder[Sales Person] )

 

2. Create a slicer using SalesPersonSlicer.

 

3. Create measure:

 

OrdersDeliveredBySalespersonAndStage = 
VAR vOrderCounts =
    ADDCOLUMNS (
        VALUES ( salesorder[Order] ),
        "@RowCount", CALCULATE ( COUNTROWS ( salesorder ) ),
        "@RowCountSalesPerson",
            CALCULATE (
                COUNTROWS ( salesorder ),
                TREATAS ( VALUES ( SalesPersonSlicer[Sales Person] ), salesorder[Sales Person] )
            )
    )
VAR vResult =
    COUNTROWS ( FILTER ( vOrderCounts, [@RowCount] = [@RowCountSalesPerson] ) )
RETURN
    vResult

 





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

Proud to be a Super User!




View solution in original post

4 REPLIES 4
tmears
Helper III
Helper III

sorry I have been on holiday.  Thank you so much, this works, you are a life saver (and time Saver!)

Now comes the next issue. the scope has now changed and people want to selected multiple sales people to compare.  the problem arises when in certain cases the selected sales people have worked on the same order.
I will try to exaplain:
If i have the following data

Order 

Order StageSales PersonPassed
Order 1Stage 1Sales Person 1Passed
Order 1Stage 2Sales Person 1 Passed
Order 2Stage 1Sales Person 1Failed
Order 2Stage 2Sales Person 2

Failed

Order 3STage 1Sales Person 3Failed
Order 3Stage 2Sales Person 1Passed


and i have selected Sales person 1 and 2 on the slicer 

Presently i get the following results 
Sales Person 1 = 2
Sales Person 2 = 1
sales Person 3 = 0

want it should be is 
Sales Person 1 = 1
Sales Person 2 = 0
sales Person 3 = 0

i know why as @RowCountSalesPerson will be returning for both sales person 1 and 2 on Order 2 as they are both on the order?  but no idea how to deal with this, if indeed I can

tmears
Helper III
Helper III

thanks so much for your reply. not sure this will achieve what i am looking for.  I also need to filter by sales person.  basically i am trying to work as an example is  if i selected stage 1 and 2, how many orders individual sales people have done, when they were the sales person on both these stages.  if they are not the sales person on both stages, this data is exclude.  Form the highlight data if i selcted 1 and 2, it would retunr 1 if i had obviously on a normal slicer it will return if they were the sales person on either of these stages 

@tmears,

 

Try this:

 

1. Create calculated table (no relationships):

 

SalesPersonSlicer = DISTINCT ( salesorder[Sales Person] )

 

2. Create a slicer using SalesPersonSlicer.

 

3. Create measure:

 

OrdersDeliveredBySalespersonAndStage = 
VAR vOrderCounts =
    ADDCOLUMNS (
        VALUES ( salesorder[Order] ),
        "@RowCount", CALCULATE ( COUNTROWS ( salesorder ) ),
        "@RowCountSalesPerson",
            CALCULATE (
                COUNTROWS ( salesorder ),
                TREATAS ( VALUES ( SalesPersonSlicer[Sales Person] ), salesorder[Sales Person] )
            )
    )
VAR vResult =
    COUNTROWS ( FILTER ( vOrderCounts, [@RowCount] = [@RowCountSalesPerson] ) )
RETURN
    vResult

 





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

Proud to be a Super User!




DataInsights
Super User
Super User

@tmears,

 

Try this measure:

 

OrdersDeliveredBySalespersonAndStage = 
IF ( DISTINCTCOUNT(salesorder[Sales Person]) > 1, 0, 1 )

 

DataInsights_0-1705353840010.png

 

-----

 

DataInsights_1-1705353854803.png

 





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

Proud to be a Super User!




Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.