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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mjohnsonsmi
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

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
ricardocamargos
Continued Contributor
Continued Contributor

Hi @mjohnsonsmi,

 

Could you provide a dataset as sample ?

 

Thanks,

 

Ricardo

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

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

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.

Hi @mjohnsonsmi.

 

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

 

 

Ricardo

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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