cancel
Showing results for
Did you mean:
Frequent Visitor

## If statement to show one salesman's name vs sales manager based on filters

Hello,

I have to be missing something silly here. I can't find anything online or in the boards that fits my specific quirk.

I have a dashboard that show's a salesman's metrics for his territory. Since this report can be printed for them to hand off it needs to display their name. A sales manager doesn't have a territory assigned so he can see everyone's information.

What I'm trying to do is an if statement that determines if 1 salesman is selected (since each guy can only see their information) to show that name. If more than one is selected (like when the sales manager is looking at all territories) it shows his name.

My logic is...

If NumberOfSelectedSalesman > 1

Show Sales Manager,

Show Salesman

This is my code. It counts all 5 salesmen no matter the filter selection, so it always shows the sales manager. Thoughts?

SelectedSalesman =
VAR SelectedSalesman =
VALUES ( Table[SalesmanName] )
VAR NumberOfSelectedSalesman =
CALCULATE ( COUNTROWS ( SelectedSalesman ) )
RETURN
NumberOfSelectedSalesman // Used for troubleshooting, shows 5 salesmen selected
& IF (
NumberOfSelectedSalesman > 1,
"Sales Manager",
Table[SalesmanName]
)

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Frequent Visitor

## Re: If statement to show one salesman's name vs sales manager based on filters

Well, my life got easier all of a sudden. This requirement is no longer needed. Thank you though!

6 REPLIES 6
Highlighted
Continued Contributor

## Re: If statement to show one salesman's name vs sales manager based on filters

Hi @mjohnsonsmi,

Could you provide a dataset as sample ?

Thanks,

Ricardo

Highlighted
Frequent Visitor

## Re: If statement to show one salesman's name vs sales manager based on filters

Sure thing, sorry.

VARs

• SelectedSalesman I've tried as a measure and a column
• NumberOfSelectedSalesman is supposed to count the number of selected rows of the salesman table (I suspect the problem is on this one)

Salesman Table

1. Bob
2. Sam
3. Tyler
4. Joe
5. Chris
Highlighted
Continued Contributor

## Re: If statement to show one salesman's name vs sales manager based on filters

Hi @mjohnsonsmi,

Try this code:

_Salesman =
VAR selected = ALLSELECTED(Table1[Salesman])
VAR returnValue = IF(COUNTROWS(selected) > 1; "Sales Manager"; DISTINCT(Table1[Salesman]))
RETURN
returnValue

Ricardo

Highlighted
Frequent Visitor

## Re: If statement to show one salesman's name vs sales manager based on filters

Thank you Ricardo, unfortunately it's doing the same behavior. It only shows the sales manager no matter what's selected. I had to change the semicolons in the IF to commas also (for anyone reading this).

Something I forgot to mention, the salesman field that does the filtering has many records in the table. Sales records with the owner (salesman) indicated, although there are only the 5 distinct salesman names.

Highlighted
Continued Contributor

## Re: If statement to show one salesman's name vs sales manager based on filters

Hi @mjohnsonsmi.

Can u provide a print of your screen, with your visual and slicers (current and what u want) ?

Ricardo

Highlighted
Frequent Visitor

## Re: If statement to show one salesman's name vs sales manager based on filters

Well, my life got easier all of a sudden. This requirement is no longer needed. Thank you though!

Announcements

#### Microsoft Ignite

This will be a conference that you do not want to miss!

#### Get Ready for Power BI Dev Camp

Don't miss the Power BI Dev Camp this week!

#### August Community Highlights

Check out a full recap of the month!

#### August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

#### Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors