cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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!

View solution in original post

6 REPLIES 6
Highlighted
Continued Contributor
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
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
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!

View solution in original post

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.

Top Solution Authors
Top Kudoed Authors